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?
Put
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
befor closing the system.serviceModel tag. It should end like this:
<system.serviceModel >
.
.
.
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel >
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.
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 (WCF (hosting service in IIS) - machine name automattically being picked up by WCF rather than IP?).
精彩评论