tags:

views:

480

answers:

2

So, I'm a newbie to WCF...

I created my ServiceLibrary and web-site project that consumed the ServiceLibrary. I am able to access the service by creating a proxy class from the WSDL that was generated using svcutil.exe and then used this class to access the methods in my service. All of this was fine on my local machine.

I then moved the service to my test development server (not on the domain, so I am accessing via an IP address) and added the site to IIS. I was able to access the service via //ip/ServiceSite/Service.svc and the WSDL via //ip/ServiceSite/Service.svc?wsdl.

However, when trying to consume this service I received an error about references being incorrect. When I look at the //ip/ServiceSite/Service.svc the link that is provided to generate the proxy class contains the machine name of the server in the address and when I look at the WSDL the references to the schemas also contain the machine name in the URL. This machine name cannot be accessed over the network as it is not on the domain.

Is there a way that instead of the machine name for the server being placed in those references that it would use the IP address? Or are there any other solutions to be able to access the service by IP address?

+1  A: 

I think I may have found a solution, which was to change the IIS site binding to be that of the IP address. I still don't understand why this can't be a setting in the .config file.

Here is the link to the solution that I found (http://blogs.msdn.com/wenlong/archive/2007/08/02/how-to-change-hostname-in-wsdl-of-an-iis-hosted-service.aspx).

Here is a link to my post about finding the solution (http://stackoverflow.com/questions/1941900/wcf-hosting-service-in-iis-machine-name-automattically-being-picked-up-by-wcf).

dwhittenburg
When hosting in IIS, it is the IIS binding that determines what's emitted into the service references. You'll see whatever IIS wants you to see - what's in the binding.
John Saunders
I changed the binding to be ":80:[serverip]".
dwhittenburg
i guess my question is, why isn't there a setting in the web.config to use ip vs machine name?
dwhittenburg
+2  A: 

Take a look at the WCFExtras library. In particular, the section on "Override SOAP Address Location URL". The brief answer is that you need a custom endpoint behavior provided by implementing IWsdlExportExtension.ExportEndpoint.

Craig