Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1046471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:09:05+00:00 2026-05-16T16:09:05+00:00

I am using the sample code to dynamically invoke a web service from this

  • 0

I am using the sample code to dynamically invoke a web service from this site:
http://www.crowsprogramming.com/archives/66

The issue that I am facing is when I use the Class to call a web service from a web application I get the following error: “The remote host cannot be found” and the error happens at the following line of code:
if (!ServiceDescription.CanRead(xmlreader))

But if I use the same code from a windows application to connect to the web service:
http://www.w3schools.com/webservices/tempconvert.asmx?WSDL

it works fine. I am not sure how to resolve this issue. Has anyone else faced the same issue and was able to resolve it then would appreciate some pointers in the right direction.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:09:05+00:00Added an answer on May 16, 2026 at 4:09 pm

    The issue for me was the Proxy to be used to connect to the internet. The code needs to change at the following two places for the successful operation:

    1] The method BuildServiceDescriptionImporter(XmlTextReader xmlreader) was changed to

        private ServiceDescriptionImporter BuildServiceDescriptionImporter( string webserviceUri )
        {
            ServiceDescriptionImporter descriptionImporter = null;
    
            **WebClient client = new WebClient { Proxy = new WebProxy( string host, int port ) };**
    
            Stream stream = client.OpenRead( webserviceUri );
    
            XmlTextReader xmlreader = new XmlTextReader( stream );
    
            // parse wsdl
            ServiceDescription serviceDescription = ServiceDescription.Read( xmlreader );
    
            // build an importer, that assumes the SOAP protocol, client binding, and generates properties
            descriptionImporter = new ServiceDescriptionImporter();
            descriptionImporter.ProtocolName = "Soap12";
            descriptionImporter.AddServiceDescription( serviceDescription, null, null );
            descriptionImporter.Style = ServiceDescriptionImportStyle.Client;
            descriptionImporter.CodeGenerationOptions = CodeGenerationOptions.GenerateProperties;
    
            return descriptionImporter;
        } 
    

    2] The second piece of code that was to be changed was within the public T InvokeMethod<T>( string serviceName, string methodName, params object[] args ) method

    add the following code snippet before Invoking the method:

    PropertyInfo Proxy = type.GetProperty( "Proxy" );
    
    WebProxy webProxy = new WebProxy( string host, int port);
    
    Proxy.SetValue( serviceInstance, webProxy, null );
    

    After doing those changes I was able to use the code to connect to a remote web service dynamically.

    Hope this helps others facing the same issue as I did.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using the sample code from this d3 project to learn how to
I'm using the Dynamic LINQ library code sample to dynamically return some data. The
This is a sample code of my program. Here I am dynamically allocating memory
I have a Dictionary bound to DataGridView by using following sample code. DataGridView bound
I'm working through Beej's socket tutorial . Using the sample code I've created a
So I have a few properties that I'm using in some sample code I'm
I am using something like the above sample code but when i try to
I'm using SS 2005 if that I've seen sample code like DECLARE @restore =
Does anyone know if there is an sample code for using Visual Basic to
I have created a CPTTradingRangePlot using the up-to-date sample code as an example. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.