Tuesday, September 22, 2009

VS2008: Adding Web Service Reference, not hosted at default 80 port

Today I come across an issue while trying to consume a third party web service for B2B integration project. The web service has been hosted on some port i.e. 8097 other then default 80 port for IIS. When I try to add the web service reference in to my VS 2008/ ASP.Net 2.0 project it gives me this error:

Metadata contains a reference that cannot be resolved: 'http://test.org/myservice/service.asmx?wsdl'.
There was an error downloading 'http:// test.org/myservice/service.asmx?wsdl '.
Unable to connect to the remote server

The web service i have been trying to include in my project was hosted at 'http://test.org:8097/myservice/service.asmx'

I 'Binged' the problem, but I can't find anything, lot of people have put this problem but I didn't found any solution..

Here are the steps I took in order to resolve this problem:

  1. Add this web reference 'http://test.org:8097/myservice/service.asmx?wsdl' instead of default, it will generate the proxy but still you won't be able to call the web service.
  2. Next step is to go to Settings.settings in property folder of you project, open it you'll find a URL entry for your web service, its type is 'Web Service URL'. Go and change its value to 'http://test.org:8097/myservice/service.asmx'
  3. Now check the web.config entry for your web service URL and make sure that it points to the correct URL with port included in it. [you need to do this step if the web service URL behavior is 'dynamic' ]

Happy Coding!

No comments: