这可能是由于服务终结点绑定未使用 HTTP 协议造成的 原因数据量过大
今天又看到"这可能是由于服务终结点绑定未使用 HTTP 协议造成的" 这个蛋疼的错误
这个错误之前也遇到过多次 归纳原因有
1、没有重新生成代理文件
2、这是因为WCF返回值无法序列化造成的
但我今天遇到时 我想这次肯定不是这两个原因之一 我想应该是数据量过大 于是把数据减少一部分后 一切正常 那就找解决方案 最后看到 这个帖子 http://topic.csdn.net/u/20080708/08/8158eac6-08fd-4e04-b37d-7dfc8137a6d9.html?seed=937996111&r=60490402#r_60490402 按文中的配置方法配置后 问题解决。
既然是好东西 那我就“偷”来 呵呵
解决方法:
用SvcConfigEditor为客户端和服务端都加上一个behavior (服务端添加servicehehavior, 客户端添加endpointbehavior),然后为这两个服务各添加一个dataContractSerializer,把他的maxItemsInObjectGraph字段变成更大的数。
服务端配置:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="NewBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8000/ContactManager/md" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="65536000" /> </behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="NewBehavior" name="WcfServiceLibrary1.ContactManager">
<endpoint address="http://localhost:8000/ContactManager" binding="wsHttpBinding"
bindingConfiguration="NewBindingStationCnfg" contract="WcfServiceLibrary1.IContactManager" />
<endpoint address="http://localhost:8000/ContactManager/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="NewBindingStationCnfg" maxReceivedMessageSize="483647" />
</wsHttpBinding>
</bindings>
</system.serviceModel>
客户端的config:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior">
<dataContractSerializer maxItemsInObjectGraph="6553600" />
</behavior>
</endpointBehaviors> </behaviors>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true" />
</diagnostics>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IContactManager1" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/ContactManager" behaviorConfiguration="NewBehavior"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IContactManager1"
contract="ServiceReference2.IContactManager" name="WSHttpBinding_IContactManager1">
<identity>
<userPrincipalName value="vblab1@redmond.corp.microsoft.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
作者:代码哥
出处:http://daimage.cnblogs.com/
说明:本博原创文章版权归博客园和本人共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出作者名称和原文连接,否则保留追究法律责任的权利。