本文介绍了WCF - 客户端和>服务绑定可能不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

客户端配置:

 <结构>
    < system.serviceModel>
        <绑定>
            < basicHttpBinding的>
                <绑定名称=BasicHttpBinding_IServicecloseTimeout =00:01:00
                    openTimeout =00:01:00receiveTimeout =00:10:00的SendTimeout =00:01:00
                    allowCookies =假bypassProxyOnLocal =假hostNameComparisonMode =StrongWildcard
                    maxBufferSize =65536maxBufferPoolSize =524288maxReceivedMessageSize =65536
                    messageEncoding =MTOMtextEncoding =UTF-8transferMode =缓冲
                    useDefaultWebProxy =真正的>
                    < readerQuotas MAXDEPTH =32maxStringContentLength =8192maxArrayLength =16384
                        maxBytesPerRead =4096maxNameTableCharCount =16384/>
                    <安全模式=无>
                        <交通运输clientCredentialType =无proxyCredentialType =无
                            境界=/>
                        <消息clientCredentialType =用户名algorithmSuite =默认/>
                    < /安全>
                < /装订>
            < / basicHttpBinding的>
        < /绑定>
        <客户端>
            <端点地址=HTTP://本地主机:1371 / Service.svc
                绑定=basicHttpBinding的bindingConfiguration =BasicHttpBinding_IService
                合同=Service.IServiceNAME =BasicHttpBinding_IService/>
        < /客户>
    < /system.serviceModel>
< /结构>
 

服务器配置:

 <绑定>
       < basicHttpBinding的>
          <绑定名称=BasicHttpBinding_IServicecloseTimeout =00:01:00
             openTimeout =00:01:00receiveTimeout =00:10:00的SendTimeout =00:01:00
             allowCookies =假bypassProxyOnLocal =假hostNameComparisonMode =StrongWildcard
             maxBufferSize =2147483647maxBufferPoolSize =524288maxReceivedMessageSize =2147483647
             messageEncoding =MTOMtextEncoding =UTF-8transferMode =流媒体
             useDefaultWebProxy =真正的>
             < readerQuotas MAXDEPTH =2147483647maxStringContentLength =2147483647
                maxArrayLength =2147483647maxBytesPerRead =2147483647maxNameTableCharCount =2147483647/>
             <安全模式=无>
                <交通运输clientCredentialType =无proxyCredentialType =无
                   境界=/>
                <消息clientCredentialType =用户名algorithmSuite =默认/>
             < /安全>
          < /装订>
< / basicHttpBinding的>
    < /绑定>
 

解决方案

从删除 messageEncoding 位的 basicHttpBinding的结合。目前它设置为MTOM的犯规让的为text / xml 的传输。

更多信息这里。

Error:

Client Config :

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <security mode="None">
                        <transport clientCredentialType="None" proxyCredentialType="None"
                            realm="" />
                        <message clientCredentialType="UserName" algorithmSuite="Default" />
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1371/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                contract="Service.IService" name="BasicHttpBinding_IService" />
        </client>
    </system.serviceModel>
</configuration>

Server Config :

<bindings>
       <basicHttpBinding>
          <binding name="BasicHttpBinding_IService" closeTimeout="00:01:00"
             openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
             allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
             maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
             messageEncoding="Mtom" textEncoding="utf-8" transferMode="Streamed"
             useDefaultWebProxy="true">
             <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
                maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
             <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                   realm="" />
                <message clientCredentialType="UserName" algorithmSuite="Default" />
             </security>
          </binding>
</basicHttpBinding>
    </bindings>
解决方案

Remove the messageEncoding bit from your basicHttpBinding binding. It's currently set to "MTOM" which doesnt allow text/xml transmission.

More info here.

这篇关于WCF - 客户端和&GT;服务绑定可能不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 22:57