WCF-Communication with multiple endpoints

73 views Asked by At

I have a problem. I try to build a WCF Communication with multiple entpoints. But it never works and it displays a ErrorMessage like this:

  • The contract name '{0}' could not be found in the list of contracts implemented by the service '{1}'.

And this is my Config-File:

*

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="MwWcfLibrary.Service">

        <endpoint address="net.tcp://localhost:8733" 
                  binding="netTcpBinding"
                  bindingConfiguration=""
                  bindingName="Action"
                  name="ActionInterface" 
                  contract="MwWcfLibrary.Actions.Interfaces.IAction">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex"
                  binding="mexTcpBinding"
                  bindingConfiguration=""
                  name="Mex"
                  contract="IMetadataExchange" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint binding="netTcpBinding"
                  address="net.tcp://localhost:8733"
                  bindingConfiguration=""
                  name="LifeSignInterface"
                  bindingName="LifeSign"
                  contract="MwWcfLibrary.LifeSign.Interfaces.ILifeSign" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint binding="netTcpBinding"
                  address="net.tcp://localhost:8733"
                  bindingConfiguration=""
                  name="DataInterface"
                  bindingName="Data"
                  contract="MwWcfLibrary.Notification.Interfaces.IData">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint binding="netTcpBinding"
                  address="net.tcp://localhost:8733"
                  bindingConfiguration=""
                  name="PublicDataInterface"
                  bindingName="PublicData"
                  contract="MwWcfLibrary.PublicData.Interfaces.IPublicData" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint binding="netTcpBinding"
                  address="net.tcp://localhost:8733"
                  bindingConfiguration=""
                  name="PublicStateInterface"
                  bindingName="PublicState"
                  contract="MwWcfLibrary.PublicState.Interfaces.IPublicState" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>

        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:8733//MwWcfLibrary" />
          </baseAddresses>
          <timeouts closeTimeout="00:00:30" />
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

*

Does someone figure out if i configured something wrong?

Kind Regards.

1

There are 1 answers

4
reckface On BEST ANSWER

EDIT

You either haven't implemented one of these interfaces: MwWcfLibrary.Actions.Interfaces.IAction, MwWcfLibrary.LifeSign.Interfaces.ILifeSign, MwWcfLibrary.PublicData.Interfaces.IPublicData and MwWcfLibrary.PublicState.Interfaces.IPublicState

or one or more of them is not decorated with the [ServiceContract] attribute

Include the actual error in your question instead of '{0}', you'll see that some of your contracts have not been implemented by the class Service which should look like this (at least):

class Service : IAction, ILifeSign, IPublicData, IPublicState
{
  // implementation
}

Also, your address attributes don't appear to be correct, since you've defined a base address ending with a segment //Mww... yet in your endpoints the address is shorter than the base address. The endpoint addresses can just be relative like "Service".

Previously

The Service element refers to a class that's an implementation of a ServiceContract interface, which is what goes into the endpoint contract attribute. Verify the fully qualified names of your interfaces and classes in theses attributes.

From looking at your configuration file, you are saying that the class MwWcfLibrary.Service implements the ([ServiceContract] decorated) interfaces called MwWcfLibrary.Actions.Interfaces.IAction, MwWcfLibrary.LifeSign.Interfaces.ILifeSign, MwWcfLibrary.PublicData.Interfaces.IPublicData and MwWcfLibrary.PublicState.Interfaces.IPublicState

That seems to be in error. Do you mean to have two services, each with a separate endpoint?