【发布时间】:2010-10-21 12:58:18
【问题描述】:
我遇到了这个明显常见的问题,但一直无法解决。
如果我调用我的 WCF Web 服务并在数组参数中使用相对较少的项目(我已经测试了多达 50 个),那么一切都很好。
但是,如果我使用 500 个项目调用 Web 服务,则会收到错误请求错误。
有趣的是,我在服务器上运行了Wireshark,看起来请求甚至没有到达服务器 - 客户端正在生成 400 错误。
例外情况是:
System.ServiceModel.ProtocolException:远程服务器返回意外响应:(400) 错误请求。 ---> System.Net.WebException:远程服务器返回错误:(400)错误请求。
我的客户端配置文件的 system.serviceModel 部分是:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" 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="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://serviceserver/MyService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="SmsSendingService.IMyService" name="WSHttpBinding_IMyService" />
</client>
</system.serviceModel>
在服务器端,我的 web.config 文件有以下 system.serviceModel 部分:
<system.serviceModel>
<services>
<service name="MyService.MyService" behaviorConfiguration="MyService.MyServiceBehaviour" >
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyService.MyServiceBinding" contract="MyService.IMyService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MyService.MyServiceBinding">
<security mode="None"></security>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyService.MyServiceBehaviour">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
我有 looked at 和 fairly large number answers 到 this question 和 no success。
谁能帮我解决这个问题?
【问题讨论】:
-
如果没有到达服务器,可能是发送的数据有问题。也许请求中有一些非法字符?还假设这是 SOAP
-
所以您尝试将所有“最大”属性(例如 maxReceivedMessageSize...)设置为一个非常高的数字?
-
是的,它是 SOAP。并且请求应该没有任何问题 - 正如我所说,对于使用同一应用程序生成的多达 50 个元素,一切正常......
-
@mundeep - 是的 - 我尝试将它们全部设置为 2147483647,但没有运气。我链接到的一些页面实际上表明对所有属性都这样做是一件坏事......
标签: c# .net wcf web-services