locked
Web Service getting "Unable to connect to remote Server"

    Question

  • I have a very simple windows form with a button that calls a very simple web service.  The web service should just return "true".  When I run within visual studio, it works correctly and I can see the .net development server running.  However, if I close visual studio and try to run the application, I get "Unable to connect to remote server". 

    I created the web service in c# using visual studio 2005 and I selected "File System" for the location option but specified C:\Inetpub\wwwroot\TestConnection as the folder location.  I am using .net 2.0, IIS 5.1, and asp.net 2.0.50727.  I created a web setup project for the web service and ran the install.  From IIS management, I can see the virtual directory and can browse the .asmx file and do a test invoke of the method without any trouble.

    From what I have read, it seems to me that the web service isn't using IIS as it's web server and so it doesn't work unless I am in visual studio where it uses the .net web development server but I don't understand why.

    Any help would be greatly appreciated!

     Thank you.

    Linda

    Wednesday, November 08, 2006 7:29 PM

Answers

  • Using the publish functionality did not work.  Apparently, visual studio stores a a port number embedded in the url string in the web reference.  Somehow this port number indicates that IIS should not be used.  I was able to store the url in the application settings and then remove the port number at run time and that worked.  However, updating the web reference from within visual studio overwrites the setting. 

    My final solution was to delete the web reference from my windows app, remove the web service project from my solution, then say "add existing web site" and select Local IIS, then add the new web reference to my windows app.

    Thanks for your help.

    Friday, November 10, 2006 6:02 PM

All replies

  • Linda,

    What exactly you don't understand of all this?

    Regards,

    Rodrigo

    Wednesday, November 08, 2006 8:05 PM
  • I don't understand how to force my web service to use IIS as the web server when I run outside visual studio or in a production environment.  Every time I try to run my application outside of visual studio, I get "Unable to connect to remote server." and the web service doesn't execute.
    Wednesday, November 08, 2006 8:44 PM
  • Well, in that case you should use "IIS" as the location so your WS resides in IIS and can be executed whenever you want.

    For production deployment you can also use the "publish" functionality from VS.

    Regards

    Rodrigo

    Wednesday, November 08, 2006 10:55 PM
  • Using the publish functionality did not work.  Apparently, visual studio stores a a port number embedded in the url string in the web reference.  Somehow this port number indicates that IIS should not be used.  I was able to store the url in the application settings and then remove the port number at run time and that worked.  However, updating the web reference from within visual studio overwrites the setting. 

    My final solution was to delete the web reference from my windows app, remove the web service project from my solution, then say "add existing web site" and select Local IIS, then add the new web reference to my windows app.

    Thanks for your help.

    Friday, November 10, 2006 6:02 PM
  • Hi,

       I am creating one simple web service named as add.asmx on remote machine. and i want to use this web service to another machine in asp.net 2.0 application. i will add reference to that web service by right clicking on refference, it give three options, from that three options i choose web service on UDDI, but it gives me an error that no web service found. if i write URL on listbox that is http://myservermachinename/foldername/webservicename.asmx then also it give error that page not found

    so, please tell me how to use web service on remote machine (which is not published) to my machine

    thanks,

    Monday, October 08, 2007 5:13 AM
  • I have always had the web service on my local machine during development so I am sorry, I don't know the answer to your question.

     

    Tuesday, October 09, 2007 1:38 PM
  • Try re-installing the .Net Framework 2.

     

    Tuesday, October 23, 2007 3:23 PM
  •  

    Tuesday, October 23, 2007 3:23 PM
  • Actually "File System" is the problem bcoz when we use file system there is a port number created.Once The server unable to find the port then its shows the error "unable to connect with the remote server". Do one thing try with http

    and check..

     

    Wednesday, October 24, 2007 7:25 AM
  •  

    string proxyUrl = "http:/YourProxu:YourPort";

    WebProxy proxy = new WebProxy(proxyUrl, true);

    YourWebService.Proxy = proxy;

     

    I Hope this helps.

    Wael M. Ibnahim

     

    Wednesday, October 31, 2007 9:48 AM
  • In case you are behind proxy / firewall, there might be a System.Net Exception error you get at catch.  To solve that, use the following settings in the Web.Config.  You need to place the following settings above <system.web> start tag or after the </system.web> end tag, basically outside the system.web settings.

    <system.net>
        <defaultProxy>
          <proxy usesystemdefault="False"
                 proxyaddress="Specify Your Proxy Address: Specify Port Number"
    bypassonlocal="False"/>
        </defaultProxy>
      </system.net>

     

    I Hope this solution works too ...

    Wael M. Ibrahim

    Wednesday, October 31, 2007 9:52 AM
  • it was Port # for me, i ran the website under IIS contex and same ws worked for me.. 
    Wednesday, December 29, 2010 9:51 PM