WCF.NET service references use the server name and not the IP address causing problems when using

So I'm new to WCF ...

I created a ServiceLibrary project and a website that used ServiceLibrary. I can access the service by creating a proxy class from WSDL , which was generated using svcutil.exe, and then used this class to access the methods in my service. All this was good on my local machine.

Then I transferred the service to my test development server (not to the domain, so I get access through the IP address) and added the site to IIS . I was able to access the service through //ip/ServiceSite/Service.svc and WSDL via //ip/ServiceSite/Service.svc?wsdl.

However, trying to use this service, I got an error about invalid links. When I look at //ip/ServiceSite/Service.svc, the link that is provided to create the proxy class contains the server computer name in the address, and when I look at WSDL, the links to the schemes also contain the machine name in the URL. This machine name cannot be accessed over the network because it is not in a domain.

Is there a way, instead of the machine name, to host the server in those links that it will use the IP address? Or are there other solutions for accessing the service by IP address?

+4
source share
3 answers

Put

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 

to close the system.serviceModel tag. It should end like this:

 <system.serviceModel > . . . <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel > 
+10
source

Take a look at the WCFExtras library. In particular, the section "Overriding the URL address of the SOAP address." The short answer is that you need a custom endpoint provided when implementing IWsdlExportExtension.ExportEndpoint.

+2
source

I think I found a solution that was supposed to change the binding of the IIS site to the IP address. I still don't understand why this cannot be a parameter in the .config file.

Here is a link to the solution 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 a solution ( WCF (hosting service in IIS) is the machine name automatically selected by WCF, not IP? ).

+1
source

All Articles