I have a simple Webserivce (WCF) hosted in a Windows Service(Selfhost). The declaration of the service looks like this :
<service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
<endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8008/MyAppServiceutv/Integration"/>
</baseAddresses>
</host>
</service>
I can brows the WSDL with this URL :
http://localhost:8008/MyAppServiceutv/Integration?wsdl
When adding the service reference in Visual Studio 2012 I get this exception :
Exception
The document was understood, but it could not be processed.
http://localhost:8008/MyAppServiceutv/Integration?xsd=xsd0
'.Metadata contains a reference that cannot be resolved: 'http://MyComputer:8008/MyAppServiceutv/Integration?wsdl
'.
Content Type application/soap+xml; charset=utf-8 was not supported by service http://MyComputer:8008/MyAppServiceutv/Integration?wsdl
. The client and service bindings may be mismatched.
The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'..
If the service is defined in the current solution, try building the solution and adding the service reference again.
Moving to Dev Environment
When moving the service to a dev computer everything works just great? Why whould I get the above problems in just one environment? Could this be due to strong security restrictions?
It sounds like your VS2012 instance is off box from your service host machine. Try changing your config like this...
<service behaviorConfiguration="MyApp.ServiceImplementation.MyAppIntegration_Behavior" name="MyApp.ServiceImplementation.MyAppIntegration">
<endpoint binding="basicHttpBinding" bindingConfiguration="BasicMyAppIntegration" bindingNamespace="MyApp.ServiceImplementation" contract="MyApp.ServiceContracts.IMyAppIntegration"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://{my fully qualified domain name}:8008/MyAppServiceutv/Integration"/>
</baseAddresses>
</host>
</service>
Okay. Now I have confirmed the problem...an explanation. .net 4.0 or less WCF produces multi-file WSDL files. The base WSDL file links to various files. The link that is in your WDSL file links to the other files using absolute URIs as opposed to relative URIs. So when your Visual Studio tries to find the other WDSL files it fails to find it on "localhost".
With .net 4.5 WCF can generate SINGLE FILE WSDL which will also solve your problem. But overall in my opinion WCF 4.0 is broken when dealing with WSDL proxy generation.