当前位置: 代码迷 >> Web Service >> 调用WCF传大于8K的字符串就错误,wcf一分钟报超时错误(!)
  详细解决方案

调用WCF传大于8K的字符串就错误,wcf一分钟报超时错误(!)

热度:400   发布时间:2012-03-23 12:06:21.0
调用WCF传大于8K的字符串就异常,wcf一分钟报超时异常(在线等!!!)
两个异常均是超过wcf默认配置设置,但是wcf的配置已经改得够大了,还是一样异常(重新生成过wcf,更新过wcf引用)
服务端配置:
C# code

<bindings >

            <basicHttpBinding>
                <binding name ="basicHttpBinding" maxReceivedMessageSize="2147483647" sendTimeout="00:10:00" maxBufferSize="2147483647" >
                    <readerQuotas maxStringContentLength="2147483647"/>
                    <security mode="None"></security>
                </binding>

            </basicHttpBinding>

        </bindings>



客户端配置:
C# code

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="flowbinding" sendTimeout="00:10:00" maxBufferSize="2147483647"
                 maxReceivedMessageSize="2147483647">
                    <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
                    <security mode="None">
                        <transport realm="" />
                    </security>
                </binding>
            </basicHttpBinding>
            <customBinding>
                <binding name="flowbinding">
                    <textMessageEncoding messageVersion="Default" writeEncoding="utf-8" />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:2449/JPMFlowService.svc"
             binding="basicHttpBinding" bindingConfiguration="flowbinding"
             contract="FlowService.IJPMFlowService" name="BasicHttpBinding_IJPMFlowService" />
        </client>
    </system.serviceModel>
</configuration>



------解决方案--------------------
服务端参考如下配置
XML code

<system.serviceModel>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  <services>
            <service behaviorConfiguration="ESBServiceBehavior" name="MDService">
                <endpoint binding="wsHttpBinding" bindingConfiguration="wsESBHttpBinding" contract="IMDService"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
</services>
        <bindings>
            <wsHttpBinding>
                <binding name="wsESBHttpBinding" maxReceivedMessageSize="655360">
                    <readerQuotas maxStringContentLength="655360"/>
                    <security mode="None"/>
                </binding>
            </wsHttpBinding>     
        </bindings>
<behaviors>
<serviceBehaviors>
    <behavior name="ESBServiceBehavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="true" />
     <serviceThrottling maxConcurrentCalls="1024" maxConcurrentSessions="1024"
      maxConcurrentInstances="1024" />
    </behavior>
    <behavior name="">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
    </system.serviceModel> 
  相关解决方案