I created a WCF web service in C # deployed to a Windows Service EXE, which works basically the way I want. I use it myself (not as part of IIS).
To make the WSDL file available to the calling Java web service, I added ServiceMetadataBehavior to the host creation. i.e:
ServiceHost host = new ServiceHost(typeof(MyService)); ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGetEnabled = true; host.Description.Behaviors.Add(smb); host.Open();
All this worked fine until I transferred my service to another server with a different host name. When I connect to WSDL (http: // prod-server: 55000 / MyService? Wsdl), I see that the host name of the development server is hardcoded in WSDL.
Here is a WSDL snippet as shown in the browser:
<wsdl:definitions name="MyService" targetNamespace="http://tempuri.org/"> <wsdl:import namespace="MyProject.ServiceContracts" location="http://dev-server:55000/MyService?wsdl=wsdl0"/> <wsdl:types/>
I checked all the C # code in the project, and the name of the development server is not encoded anywhere.
In the App.config file, I have the following defined:
<system.serviceModel> <services> <service name="MyService"> <endpoint address="http://localhost:55000/MyService" binding="basicHttpBinding" bindingConfiguration="" contract="MyProject.ServiceContracts.IMyInterface" /> <host> <baseAddresses> <add baseAddress="http://localhost:55000/MyService" /> </baseAddresses> </host> </service> </services>
I expect this to replace the localhost machine name, but it is saved as the name of the development window in which the service was originally created / deployed. Am I mistaken?
I also considered the possibility of explicitly specifying the path to my WSDL file, but from what I can do, this can only be done when hosting the service in IIS.
Finally, and purely out of curiosity, I wonder if the actual WSDL file (the physical file on disk that I mean) is actually being created, or is it dynamically displayed with every request?