码迷,mamicode.com
首页 > Web开发 > 详细

WCF之net.tcp

时间:2016-05-15 13:50:02      阅读:239      评论:0      收藏:0      [点我收藏+]

标签:

自己通过编写WCF服务端,在客户端直接添加服务引用时发现不能引用对netTcpBinding直接引用(net.tcp://127.0.0.1:8081),所以自己找到方法了记录以备不时之需。

服务端配置:

技术分享
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name="mexConfig">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://120.25.160.17:8080/" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <netTcpBinding>
        <binding name="MyTcpBinding" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" sendTimeout="00:30:00" transferMode="Streamed"   >
          <security mode="None"></security>
        </binding>
      </netTcpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="mexConfig" name="WCFService.Service">
        <endpoint address="net.tcp://120.25.160.17:8081/" binding="netTcpBinding"
          bindingConfiguration="MyTcpBinding" contract="WCFService.IService" />
        <endpoint address="net.tcp://120.25.160.17:8081/" binding="netTcpBinding"
          bindingConfiguration="MyTcpBinding" contract="WCFService.IMyName" />
        <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://120.25.160.17:8081/" />
          </baseAddresses>
        </host>
      </service>
    </services>
  </system.serviceModel>
</configuration>
View Code

客服端配置:

技术分享
<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <netTcpBinding>
                <binding name="NetTcpBinding_IService" transferMode="Streamed">
                    <security mode="None" />
                </binding>
                <binding name="NetTcpBinding_IMyName" transferMode="Streamed">
                    <security mode="None" />
                </binding>
            </netTcpBinding>
        </bindings>
        <client>
            <endpoint address="net.tcp://120.25.160.17:8081/" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IService" contract="wcf.IService"
                name="NetTcpBinding_IService" />
            <endpoint address="net.tcp://120.25.160.17:8081/" binding="netTcpBinding"
                bindingConfiguration="NetTcpBinding_IMyName" contract="wcf.IMyName"
                name="NetTcpBinding_IMyName" />
        </client>
    </system.serviceModel>
</configuration>
View Code

 

WCF之net.tcp

标签:

原文地址:http://www.cnblogs.com/fuchangmeng/p/5494990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!