WCF配置在不同端点上实现多个合同的服务类

时间:2010-10-14 18:17:46

标签: wcf

我有一个实现MyServiceIService1接口的IService2类。我想在两个不同的端点上公开这两个合同,例如:

  • IService1/Service/S1
  • 上曝光
  • IService2/Service/S2
  • 上曝光

这样的配置怎么样?

2 个答案:

答案 0 :(得分:3)

试试这个......

<services>      
  <service name="Service">
    <endpoint address="http://localhost:8080/Service/S1"
              binding="basicHttpBinding"
              contract="IService1"

     />

    <endpoint address="http://localhost:8080/Service/S2"
              binding="basicHttpBinding"
              contract="IService2 "

     />
  </service>
</services>

答案 1 :(得分:1)

您可以使用具有两个端点的服务,如下所示:

<services>      
  <service name="MyNamespace.MyService">
    <endpoint address="/Service/S1"
              binding="basicHttpBinding"
              contract="IService1" />
    <endpoint address="/Service/S2"
              binding="basicHttpBinding"
              contract="IService2 " />
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8080/"/>
      </baseAddresses>
    </host>
  </service>
</services>

编辑:添加了基地址