title: Communication between two WCF Services in selfhosting Server
body: <p>In a selfhosting service as described in this <a href="http://msdn.microsoft.com/en-us/library/ee939340.aspx" rel="nofollow noreferrer">MSDN article</a>
  there are two servies.</p>
  
  <p>Now I want to call one from the other. One does some database related stuff and the other provides some work. I want to use the database functionality in the other service.</p>
  
  <p>I tried to add a service reference as mentioned here: <a href="https://stackoverflow.com/questions/409373/communicate-between-2-wcf-services">Stackoverflow with similar question</a>
  but I get the message: "There was an error downloading metadata from the address",
  so adding a service reference is not possible.</p>
  
  <p>The service on their own both are running and working, as I already use them from client applications.</p>
  
  <p>This is the web.config from the service I want to use.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&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;serviceMetadata httpGetEnabled="true"/&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;/configuration&gt;
  </code></pre>
  
  <p>And here are parts from the App.config from my selfhosting service</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  
    &lt;system.serviceModel&gt;
  
     &lt;!-- omitted lots of blocks --&gt;
  
      &lt;services&gt;
  
        &lt;service name="MyProject.WorkService.GeneralWorkService" behaviorConfiguration="SimpleServiceBehavior"&gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress="http://localhost:8080/"/&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
          &lt;endpoint address="traceability" binding="basicHttpBinding" name="WorkService" contract="MyProject.Service2.Contracts.IService2"/&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
  
        &lt;/service&gt;
        &lt;service name="MyProject.DatabaseService.GeneralDatabaseService" behaviorConfiguration="SimpleServiceBehavior"&gt;
            &lt;host&gt;
              &lt;baseAddresses&gt;
                &lt;add baseAddress="http://localhost:8000/"/&gt;
              &lt;/baseAddresses&gt;
            &lt;/host&gt;
            &lt;endpoint address="gateway" binding="basicHttpBinding" name="DatabaseService" contract="MyProject.DatabaseService.Contracts.IDatabaseService"/&gt;
            &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/&gt;
        &lt;/service&gt;
  
      &lt;/services&gt;
      &lt;client&gt;
        &lt;endpoint name="Service2EP" address="http://localhost/someWork" binding="basicHttpBinding" contract="MyProject.Service2.IService2"&gt;        
        &lt;/endpoint&gt;
  
        &lt;endpoint name="DatabaseServiceEP" address="http://localhost/gateway" binding="basicHttpBinding" contract="MyProject.DatabaseService.IDatabaseService"&gt;
        &lt;/endpoint&gt;
  
  
  
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
    &lt;startup&gt;
      &lt;supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/&gt;
    &lt;/startup&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>-update-</p>
  
  <p>I can use a browser window to see my service on </p>
  
  <p><code>http://localhost:8000</code> </p>
  
  <p>Perhaps there is some other way to use my service. Should I use some proxy
  that can be generated with <code>svcutil</code>?</p>
  
  <p>Perhaps there are better ways. Adding the service reference seems not to work
  and I cannot tell why.</p>