title: WCF - Remote server returned an error: 404
body: <p>I am new to WCF and i am trying to host my first WCF application in a different machine. It works in my local machine from IIS. I hosted in the remote machine and i am able to view the WSDL. I have enabled anonymous authentication as well. </p>
  
  <p>Problem is when i try to test my .svc with SOAP UI, it errors out saying </p>
  
  <p>Error loading [http://domain.com/folder/wcfservice.svc?xsd=xsd0]: java.io.IOException: Attempted read from closed stream</p>
  
  <p>So, i tried using svcutil command and it errors out with </p>
  
  <blockquote>
    <blockquote>
      <p>Attempting to download metadata from 'http: //domain.com/folder/wcfService.svc?wsdl' using WS-Metadata Exchange or
      DISCO. Error: Cannot obtain Metadata from http:
      //domain.com/folder/wcfService.svc?wsdl WS-Metadata Exchange Error
      URI: http: //domain.com/folder/wcfService.svc?wsdl Metadata contains a
      reference that cannot be resolved: 'http:
      //domain.com/folder/wcfService.svc?wsdl'.</p>
    </blockquote>
    
    <p>There was no endpoint listening at http: //domain.com/folder/wcfService.svc?wsdl that could accept the
    message. This is often caused by an incorrect address or SOAP action.
    See InnerException, if present, for more details.</p>
    
    <p>The remote server returned an error: (404) Not Found.HTTP GET Error
        URI: http ://domain.com/folder/wcfService.svc?wsdl     The document was understood, but it could not be processed.    The WSDL document
    contains links that could not be resolved.    There was an error
    downloading 'http ://domain.com/folder/wcfService.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.    </p>
  </blockquote>
  
  <p>Here is my webconfig for your reference.</p>
  
  <pre><code>    &lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
    &lt;appSettings&gt;
      &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation targetFramework="4.0" /&gt;
    &lt;/system.web&gt;
    &lt;system.serviceModel&gt;
      &lt;behaviors&gt;
         &lt;serviceBehaviors&gt;
          &lt;behavior&gt;
            &lt;serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="false"/&gt;
          &lt;/behavior&gt;
          &lt;behavior name="defaultBehaviors"&gt;
            &lt;serviceMetadata httpGetEnabled="true"/&gt;
            &lt;dataContractSerializer maxItemsInObjectGraph="2147483646"/&gt;
            &lt;serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/&gt;
            &lt;serviceTimeouts transactionTimeout="10.00:00:00"/&gt;
          &lt;/behavior&gt;
  
        &lt;behavior name="metadataSupport"&gt;
          &lt;serviceDebug includeExceptionDetailInFaults="False" /&gt;
          &lt;!--Enable WSDL Data Binding--&gt;
          &lt;serviceMetadata httpGetEnabled="true" httpGetUrl=""/&gt;
        &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;protocolMapping&gt;
        &lt;add binding="basicHttpBinding" scheme="http" /&gt;
      &lt;/protocolMapping&gt;    
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" /&gt;    
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="wcfservice.SSO"
                   maxBufferSize="2147483647"
                   maxBufferPoolSize="2147483647"
                   maxReceivedMessageSize="2147483647"&gt;
            &lt;readerQuotas maxDepth="32"
                          maxStringContentLength="2147483647"
                          maxArrayLength="2147483647"
                          maxBytesPerRead="4096"
                          maxNameTableCharCount="16384" /&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
        &lt;service name="wcfservice.wcfservice_Service" behaviorConfiguration="defaultBehaviors"&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;   
              &lt;add baseAddress="http://domain.com/folder/wcfService.svc" /&gt;   
            &lt;/baseAddresses&gt;  
          &lt;/host&gt;
          &lt;endpoint address="xml"
                    binding="basicHttpBinding"
                    bindingConfiguration="wcfservice.SSO"
                    contract="wcfservice.Iwcfservice" /&gt;
          &lt;endpoint address="mex"
                    binding="mexHttpBinding"
                    contract="IMetadataExchange"&gt;
          &lt;/endpoint&gt;
        &lt;/service&gt;
      &lt;/services&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
      &lt;directoryBrowse enabled="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I think its worthwhile to mention that this WCF application was created in VS2012 and i just changed the targetframework to 4.0 in web.config after deployment. </p>
  
  <p>Can somebody please help what is causing the error? Am i missing something in web.config? </p>