CFXIXI工作室首页
CF西西的博客 | wcf编辑两个endpoint

wcf编辑两个endpoint

9. 四月 2013

http://keithelder.net/2008/01/17/exposing-a-wcf-service-with-multiple-bindings-and-endpoints/

有sample项目可以下载

 

示例:

xml 写绑定:

<system.serviceModel>
   <services>
      <service name="YourNamespace.MyService">
         <endpoint 
             address="ws" 
             binding="wsHttpBinding" 
             contract="YourNamespace.IMyService" />
         <endpoint 
             address="net.tcp://localhost:8787/MyService" 
             binding="netTcpBinding"
             contract="YourNamespace.IMyService" />
       <host>
           <baseAddresses>
                <add baseAddress="http://localhost:8282/" />
           </baseAddresses>
       </host>
     </service>
  </services>
</system.serviceModel>

 

在客户端调用时,如果非webhttpbinding的话可以直接将bindingConfiguration实力化client对象的时候将其作为参数传入调用即可。

.NET