locked
Unable to connect to remote server

    Question

  • I am consuming a web service getting error. This is what I did.

    From VS command prompt I created a proxy class using wsdl.exe utility.
    Added generated class (.cs file) into my project using add existing item.
    Created object of it and called method of web service.

    It is giving this "Unable to connect to remote server" error.
    But I wonder it is working perfectly fine when I created test console application and did similar things.

    Why it is not working from my existing project? Any idea?

    Thanks.

    Monday, May 17, 2010 9:08 AM

All replies

  • Can provide more info about your existing project. when you say it works fine with console application, check the following

    1. Does your existing application runs on the same machine where you ran your console application, if not, run your console application in the machine where your existing application runs

    2. check the security context that is used for connecting the web service. But this wont raise the error your mentioned above but check once.

    3. Also try whether you are able to access the web service through IE from the client machine.

     


    Jagatheesan
    Monday, May 17, 2010 12:24 PM
  • Hi Jagatheesan,

    Thanks for your reply. Here is more information:

    1. Yes I am using same machine for calling web service.

    2. Not sure about what do you mean and how to check security context. Please tell me how to check.

    3. Yes I am able to access web service url from the browser.

    This is the code calling web service:

     public string CallWS(string sRqXml)
     {
        string sRsXml = String.Empty;
        try
        {
          Namespace.WebServiceClass oWs = new Namespace.WebServiceClass();
          sRsXml = oWs.WebMethod(sRqXml);
          return sRsXml;
        }
        catch (Exception x)
        {
          return x.ToString();
        }
     }
    Monday, May 17, 2010 1:21 PM
  • I think there is some problem with the class file that you have generated via command prompt. Check whether you are able to connect to the web service by adding Service Reference to the project. If it works post your class file generated via command prompt as well the WSDL file to review.
    Jagatheesan
    Tuesday, May 18, 2010 11:43 AM
  • I think it would not be wise to put entire 1000 lines of code here.

    Problem is still not solved. I got to knwo something more.

    I have sample application which is not using any proxy from code and using default IE proxy settings, which is working. If proxy settings are provided then it it failing.

    So my guess is somewhere proxy is being assigned by calling application, which is calling my application using reflaction.

    Any idea?

    Thanks.

    Wednesday, May 19, 2010 6:40 AM
  • Does your existing(or original) project uses any proxy settings. Check that if not then your problem is nothing to do with proxy. Also call the web service by adding service reference instead of generating reference classes through command line. If it works than compare the reference classes generated through service reference and command line which might help you to locate the problem.
    Jagatheesan
    Wednesday, May 19, 2010 11:56 AM
  • Is your web service running? How is it hosted? In IIS?

     

    Try browsing to the URL of the web service using a web browser, and tell us what you see.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects
    Wednesday, May 19, 2010 10:10 PM
    Moderator
  • My code is not using any proxy directly. But from somewhere it is pulling up from calling app. I come to know this by looking following InnerException:

    A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 205.141.200.25:443

    Now above error says two scenarios timeout and responding to IP. I don't have any problem with timeout but IP related problem is the real problem. I don't assign this IP anywhere in my code. Also I checked Internet Explorer's LAN Settings which is also not using any proxy with IE. Also now I tried to add following code and assigned proxy as a null like below.

    WebServiceObject.Proxy = null;

    Still have same problem. I am assigning proxy as a null but still it is using proxy from somewhere by calling application.

    For more detail about application:

    There is one Windows Service is running and it is uses .Net remoting (.Net 2.0), which is calling my application using reflection. But I think this would not be a case for this error.

    Thanks.

    Thursday, May 20, 2010 6:23 AM
  • Hello,

    1.After creating object of proxy class , make sure that URL property of proxy class object must be set to actual url of the web service.

    I mean like this:

    WebServiceClass oWs = new Namespace.WebServiceClass();
    oWs.Url = "actual url of the web service";

    string sRsXml = oWs.WebMethod(sRqXml);

    Plz let me know the results...


    Kiran
    Saturday, July 31, 2010 8:45 PM