参数大小导致WCF服务通信异常
我有一个WCFWeb方法,它接受一个XElement对象作为参数。对于我的一个XML文件(大小为600KB左右),这很好,但是对于这个更大的XML文件(大约5MB),我马上得到了一个CommunicationException 我已经增加了绑定的邮件大小。下面是my web.config的ServiceModel部分:参数大小导致WCF服务通信异常,wcf,silverlight-3.0,wcf-binding,wcf-configuration,Wcf,Silverlight 3.0,Wcf Binding,Wcf Configuration,我有一个WCFWeb方法,它接受一个XElement对象作为参数。对于我的一个XML文件(大小为600KB左右),这很好,但是对于这个更大的XML文件(大约5MB),我马上得到了一个CommunicationException 我已经增加了绑定的邮件大小。下面是my web.config的ServiceModel部分: <system.serviceModel> <behaviors> <serviceBehaviors> <behavior
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="BIMIntegrationWS.metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<customBinding>
<binding name="BIMIntegrationWS.IntegrationService.customBinding0"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binaryMessageEncoding>
<httpTransport maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="BIMIntegrationWS.BIMIntegrationWS" behaviorConfiguration="BIMIntegrationWS.metadataBehavior">
<endpoint address="" binding="customBinding" bindingConfiguration="BIMIntegrationWS.IntegrationService.customBinding0"
contract="BIMIntegrationWS.IBIMIntegrationService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
在客户端上,我的ClientConfig如下所示:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="CustomBinding_IBIMIntegrationService">
<binaryMessageEncoding />
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://localhost:1895/IntegrationService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_IBIMIntegrationService"
contract="BIMIntegrationService.IBIMIntegrationService" name="customBindingEndpoint" />
</client>
</system.serviceModel>
提前谢谢 您可能需要更改
子元素
的属性值
有关详细信息,请参阅:
更新:
您是否可以尝试增加maxAllowedContentLength
,如下所述:
也许您的XElement有太多的节点/子元素,您需要将dataContractSerializer下的maxItemsInObjectGraph属性设置为更大的值?您知道如何关闭VS host并部署到IIS并对其进行ping操作吗。在您的开发设备上安装普通的IIS7就可以了。您仍然可以附加调试器等,只是不会有即时的F5满足感,但由于您的ocode不会在启动时消亡,因此您不需要从第一行查看:-)
如果您需要很早进行连接,您可以创建一个模拟方法,该方法完全不支持任何内容,只返回int consnat-只需打开应用程序池即可进行连接。尝试将以下代码段添加到服务应用程序的web.config中:
<system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>
在web服务器中托管服务时,还必须调整web服务器允许的请求大小
致以最良好的祝愿,
Ladislav您能发布CommunicationException详细信息吗?详细信息几乎只是说:“System.ServiceModel.CommunicationException未经用户代码处理。Message=远程服务器返回错误:NotFound。”您是否在IIS下托管服务?我仍在开发中。所以托管是在我的本地机器上完成的,通过Visual Studio的动态web服务器主机。好的,仅供参考:不要使用Cassini进行WCF开发-这是邪恶的!手动设置属性属性时运气不佳。:\我正在更新问题中包含的web.config。好的,您也可以尝试调整元素的值:有没有提示我如何调整XElement类型(或任何其他已经可序列化的类型)的值?maxAllowedContentLength属性没有做到这一点。大文件仍然出现异常。+1在原始问题中没有足够的调试信息,但我认为这可能是您遇到的问题,因为IIS中默认的最大传入请求限制为4096 KB。因为您正试图将5MB的XML推送到服务器上——轰!原始海报是否尝试过在Windows服务中而不是在IIS下自托管应用程序?如果您在Intranet环境中运行此应用程序,我建议您使用net.tcp绑定来提高性能,因为您要处理大量数据。这似乎已经做到了。非常感谢Laidslav!赏金过期了,所以我不得不重新加上。我会尽快奖励它(23小时)。再次感谢!