0

In a selfhosting service as described in this MSDN article there are two servies.

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.

I tried to add a service reference as mentioned here: Stackoverflow with similar question but I get the message: "There was an error downloading metadata from the address", so adding a service reference is not possible.

The service on their own both are running and working, as I already use them from client applications.

This is the web.config from the service I want to use.

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

And here are parts from the App.config from my selfhosting service

<?xml version="1.0"?>
<configuration>

  <system.serviceModel>

   <!-- omitted lots of blocks -->

    <services>

      <service name="MyProject.WorkService.GeneralWorkService" behaviorConfiguration="SimpleServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/"/>
          </baseAddresses>
        </host>
        <endpoint address="traceability" binding="basicHttpBinding" name="WorkService" contract="MyProject.Service2.Contracts.IService2"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

      </service>
      <service name="MyProject.DatabaseService.GeneralDatabaseService" behaviorConfiguration="SimpleServiceBehavior">
          <host>
            <baseAddresses>
              <add baseAddress="http://localhost:8000/"/>
            </baseAddresses>
          </host>
          <endpoint address="gateway" binding="basicHttpBinding" name="DatabaseService" contract="MyProject.DatabaseService.Contracts.IDatabaseService"/>
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>

    </services>
    <client>
      <endpoint name="Service2EP" address="http://localhost/someWork" binding="basicHttpBinding" contract="MyProject.Service2.IService2">        
      </endpoint>

      <endpoint name="DatabaseServiceEP" address="http://localhost/gateway" binding="basicHttpBinding" contract="MyProject.DatabaseService.IDatabaseService">
      </endpoint>



    </client>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

-update-

I can use a browser window to see my service on

http://localhost:8000

Perhaps there is some other way to use my service. Should I use some proxy that can be generated with svcutil?

Perhaps there are better ways. Adding the service reference seems not to work and I cannot tell why.

Community
  • 1
  • 1
Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113

3 Answers3

1

Are you sure that you have the mex-endpoint configured in the config of the service you are trying to reference? If you haven't the service will not expose the info required (WSDL) to make the service reference... .

W1ck3dHcH
  • 26
  • 1
0

There are at least 4 possibilities:

  • The metadata exchange mex endpoint is not defined
  • Metadata exchange is not enabled
  • You are using the wrong address
  • You are being blocked by some security setting

From There was an error downloading metadata from the address

Community
  • 1
  • 1
Alex
  • 8,827
  • 3
  • 42
  • 58
  • mex is defined in selfhosting exe, the services themselfes do not have endpoints defined. have posted the code. I already use MEX to generate a proxy for my clients. It works fine – Mare Infinitus Mar 01 '13 at 11:00
  • As I see, you have in both GeneralWorkService and GeneralDatabaseService. Try to change the address in "mex1" and "mex2". I suppose when you launch your service, there might be conflict of your two mex points as they both would have the name http://localhost:8080/mex. In IIS the full path of your service is generated by IIS itself and this example might work there. But if I not mistake - the self-hosted app just combine your base adresses with adresses of your endpoints, without modifing them – Alex Mar 01 '13 at 11:21
  • Have changed it, but this makes no difference. – Mare Infinitus Mar 01 '13 at 11:34
0

Finally found the answer.

Had to copy the endpoints from the selfhosting app.config into the service web.config.

And from that point on, the error messages in the dialog (link "Details" at the bottom) were helpful.

Just had to add the service behavior to the DatabaseService that I already have defined in the selfhosting app.config.

Thank you all for all your help. Will accept W1ck3dHcH's answer, as it was right, but I just did not see it.

Mare Infinitus
  • 8,024
  • 8
  • 64
  • 113