title: WCF Publish error: Metadata contains a reference that cannot be resolved:
body: <p>I have a WCF web service I am tryiong to publish to IIS. I can view the wsdl fine but cannot add the service in Visual Studio 2010 via the Add Service Reference menu. I get the following error:</p>
  
  <pre><code>Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc?wsdl'.
  The WSDL document contains links that could not be resolved.
  There was an error downloading 'http://localhost:4567/Service.svc?xsd=xsd0'.
  The underlying connection was closed: An unexpected error occurred on a receive.
  Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
  An existing connection was forcibly closed by the remote host
  Metadata contains a reference that cannot be resolved: 'http://localhost:4567/Service.svc'.
  Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:4567/Service.svc.  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.
  </code></pre>
  
  <p>I works great locally but not if published to IIS.</p>
  
  <p>Does anyone know what is causing this problem? Here is my web.config, I am new to WCF so might have missed something out, thanks:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
    &lt;/system.serviceModel&gt;
   &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
    &lt;connectionStrings&gt;
  
    &lt;/connectionStrings&gt;
  &lt;/configuration&gt;
  </code></pre>