zoukankan      html  css  js  c++  java
  • WCF 通过net tcp 协议 ,在服务端服务器和客户端服务器之间传输数据,注意配置事项

    1. 特别注意  binding name="BindingBehaviorConfiguration" (名字可以随意取,但是必须要服务端和客户端保持一致

        bindingConfiguration="BindingBehaviorConfiguration"

      如何没有配置保持一致:出现:服务器已拒绝客户端凭据   

        如果没有配置:security mode="None", 出现的现象:服务器已拒绝客户端凭据

    //----服务端配置实例:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>

    <system.serviceModel>
    <bindings>
    <netTcpBinding>
    <binding name="BindingBehaviorConfiguration" maxBufferPoolSize="52428800"
    maxBufferSize="6553600" maxReceivedMessageSize="6553600" portSharingEnabled="true">
    <readerQuotas maxStringContentLength="6553600" />
    <security mode="None" />
    </binding>
    </netTcpBinding>
    </bindings>
    <services>
    <service name="CDAgentWCF.Services.CDAgentWCFService" behaviorConfiguration="CDAgentWCF.Services.CDAgentWCFServiceBehavior">
    <host>
    <baseAddresses>
    <add baseAddress="net.tcp://localhost:9999/CDAgentWCF"/>
    <add baseAddress="http://localhost:9998/CDAgentWCF"/>
    </baseAddresses>
    </host>
    <endpoint address="PropellingService"
    binding="netTcpBinding"
    contract="CDAgentWCF.Services.ICDAgentWCFService" bindingConfiguration="BindingBehaviorConfiguration" />
    <endpoint address="mex"
    binding="mexHttpBinding"
    contract="IMetadataExchange" />
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="CDAgentWCF.Services.CDAgentWCFServiceBehavior">
    <serviceMetadata httpGetEnabled="True"/>
    <serviceDebug includeExceptionDetailInFaults="False" />
    <dataContractSerializer maxItemsInObjectGraph="2147483647" />
    </behavior>
    </serviceBehaviors>
    </behaviors>

    </system.serviceModel>
    </configuration>


    客户端配置实例:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
    <bindings>
    <netTcpBinding>
    <binding name="BindingBehaviorConfiguration">
    <security mode="None" />
    </binding>
    </netTcpBinding>
    </bindings>
    <client>
    <endpoint address="net.tcp://192.168.1.88:9999/CDAgentWCF/PropellingService"
    binding="netTcpBinding"
    contract="CDAgentService.CDAgentWCFService" bindingConfiguration="BindingBehaviorConfiguration">
    </endpoint>
    </client>
    <behaviors>
    <endpointBehaviors>
    <behavior>
    <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
    </behavior>
    </endpointBehaviors>
    </behaviors>
    </system.serviceModel>
    </configuration>

  • 相关阅读:
    Build-in Function:abs(),all(),any(),assii(),bin(),issubclass(),bytearray(),isinstance()
    函数及while实例
    提示'HTTP消息不可读'
    python中关于不执行if __name__ == '__main__':测试模块的解决
    python输出测试报告测试成功
    SqlServer——批量插入数据
    网页样式——各种炫酷效果持续更新ing...
    网站部署发布到互联网等整套流程
    如何远程操控别人的电脑?我来教你
    代码生成工具——CodeSmith
  • 原文地址:https://www.cnblogs.com/jeff20120716/p/4598329.html
Copyright © 2011-2022 走看看