title: Metadata contains a reference that cannot be resolved for iis hosted wcf service
body: <p>any help is appricited
  I have one Sample service and one Test console application 
  I have accessing sample service metadata by adding reference from same soln to the console appln and i am getting binding info.
  also i am hosting(publishing) same service in IIS and adding reference through service URL in Test Console appln and I am Getting result.</p>
  
  <p>Now problem is tat my running Data service hosted(published) in IIS i am adding the reference and trying to read the metadata from service URL its giving me Error.
  <strong><em>Metadata contains a reference that cannot be resolved: 'http://localhost:9092/TransactionDataService.svc/mex'</strong>.</em></p>
  
  <p>I am using mexhttpbinding with multiplebingind = true in both(sample + my running data service) cases</p>
  
  <p>web config for samp-le serviec</p>
  
  <pre><code>&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;serviceMetadata httpGetEnabled="true" httpGetUrl=""/&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;services&gt;
        &lt;service name="ServiceApp.Service1"&gt;
          &lt;endpoint address="" binding="wsHttpBinding" name="Service1Endpoint" contract="ServiceApp.IService1"/&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true"/&gt;
    &lt;/system.serviceModel&gt;
    &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"/&gt;
    &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Code for accesing metadata</p>
  
  <pre><code>EndpointAddress serviceEndpointAddress = new EndpointAddress("http://localhost:30617/Service1.svc/mex");
  
              var endpointCollection = MetadataResolver.Resolve(typeof(IService1), serviceEndpointAddress);
  
  
              foreach (var endpoint in endpointCollection)
              {
                  Type bindingType = endpoint.Binding.GetType();
  
                  if (bindingType.Equals(typeof(WSHttpBinding)))
                  {
                      Console.WriteLine("Eureka!!!");
                  }
              }
  </code></pre>
  
  <p>web config for Data service</p>
  
  <pre><code>&lt;bindings&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="WSHttp" openTimeout="01:00:00" closeTimeout="01:00:00" sendTimeout="01:00:00" receiveTimeout="01:00:00" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="0" maxReceivedMessageSize="2147483647"&gt;
            &lt;reliableSession enabled="true" /&gt;
                      &lt;readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" /&gt;
                  &lt;/binding&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
  
      &lt;!--Service Behaviors--&gt;
          &lt;behaviors&gt;
              &lt;serviceBehaviors&gt;
                  &lt;behavior name="DataAccessBehavior"&gt;
                      &lt;dataContractSerializer maxItemsInObjectGraph="2147483647" /&gt;
                      &lt;serviceMetadata httpGetEnabled="true" /&gt;
                      &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
                  &lt;/behavior&gt;
              &lt;/serviceBehaviors&gt;
          &lt;/behaviors&gt;
  
      &lt;!--Service Configuration--&gt;
          &lt;services&gt;
              &lt;service name="TransactionDataAccess" behaviorConfiguration="DataAccessBehavior"&gt;
                  &lt;endpoint name="DataAccessServiceEndpoint" address="" binding="wsHttpBinding" bindingConfiguration="WSHttp" contract="TransactionDataServices.ITransactionDataService"/&gt;
          &lt;endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange"/&gt;
              &lt;/service&gt;
          &lt;/services&gt;
          &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" /&gt;
      &lt;/system.serviceModel&gt;
      &lt;system.webServer&gt;
          &lt;modules runAllManagedModulesForAllRequests="true" /&gt;
          &lt;directoryBrowse enabled="true" /&gt;
      &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Code for accesing metadata for data service is same except serviec url</p>