zoukankan      html  css  js  c++  java
  • WCF配置

    使用VS“添加服务引用”的方式,来使用WCF服务,对于服务器端的配置需要添加mex endpoint
                                    <endpoint address="mex" binding="mexTcpBinding" name="MEX" contract="IMetadataExchange" />
        <host>
         <baseAddresses>
          <add baseAddress="net.tcp://localhost:8123/GetSimService"/>
         </baseAddresses>
        </host>
    如果移除,使用VS添加服务引用时会出现“元数据包含无法解析的引用”的异常,导致添加服务失败。
    对于启用WCF服务时出现端口被占用的情况,除了排除有其他的程序占用端口的情况,还要注意是否是因为WCF配置的问题,
    另外对于不同版本的windows系统,服务器端的配置有所不同:
    对于xp sp3 x86,listenBacklog="10"和maxConnections="10"属性不能被更改,如果能改之后会出现:
    未处理 System.ServiceModel.AddressAlreadyInUseException
      Message=已有针对 IP 终结点 0.0.0.0:8123 的侦听器。

    请确保没有在应用程序中多次尝试使用此终结点,也没有其他应用程序在侦听此终结点。

    如下图所示,让listenBacklog,maxConnections element保持默认值则不会出现异常。
                <bindings>
       <netTcpBinding>
        <!--<binding name="tcpbinding" transactionFlow="true"/>-->
        <binding name="tcpbinding" closeTimeout="00:10:00" openTimeout="00:10:00"
                        receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false"
                        transferMode="Buffered" transactionProtocol="OleTransactions"
                        hostNameComparisonMode="StrongWildcard" listenBacklog="10"
                        maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10"
                        maxReceivedMessageSize="2147483647">
         <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
         <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
         <security mode="Transport">
          <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
          <message clientCredentialType="Windows" />
         </security>
        </binding>
       </netTcpBinding>
      </bindings>

        <bindings>
     对于windows 2008 R2 x64,要移除listenBacklog、maxConnections这两个属性,否则同样会出现System.ServiceModel.AddressAlreadyInUseException异常,启用服务时,出现端口被占用的情况。
        <bindings>
          <netTcpBinding>
            <!--<binding name="tcpbinding" transactionFlow="true"/>-->
            <binding name="tcpbinding" closeTimeout="00:10:00" openTimeout="00:10:00"
                        receiveTimeout="00:10:00" sendTimeout="00:10:00" transactionFlow="false"
                        transferMode="Buffered" transactionProtocol="OleTransactions"
                        hostNameComparisonMode="StrongWildcard"
                        maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
                        maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                            enabled="false" />
              <security mode="Transport">
                <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
                <message clientCredentialType="Windows" />
              </security>
            </binding>
          </netTcpBinding>
        </bindings>
    从这些天学习WCF经验,由于接触时间不长,出现了各种各样的错误,到最后都是因为WCF的配置错误导致的,应该引以为鉴。

  • 相关阅读:
    Redis作者谈Redis应用场景(转)
    程序员必读书籍及导读指南(转)
    Python迭代器包itertools(转)
    Flash 0day漏洞(CVE-2018-4878)复现
    第二届“强网杯”全国网络安全挑战赛来袭——线上赛
    网站漏洞——文件判断函数的安全风险(实战篇)
    Android逆向进阶——让你自由自在脱壳的热身运动(dex篇)
    【python入门】之教你编写自动获取金币脚本
    Python大法之从火车余票查询到打造抢Supreme神器
    读DEDECMS找后台目录有感
  • 原文地址:https://www.cnblogs.com/goxmpx/p/3314358.html
Copyright © 2011-2022 走看看