我有一个WCF Web MEthod,它接受一个XElement对象作为参数。对于我的一个XML文件(大小为600KB左右),这个工作得很好,但是,对于这个更大的XML文件(大约5MB),我立刻得到了一个CommunicationException。
我已经增加了绑定的邮件大小。下面是我的web.config的ServiceModel部分:
<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>
提前致谢!
答案 0 :(得分:1)
您可能需要更改<readerQuotas />
的{{1}}子元素的属性值。
有关详细信息,请参阅: http://msdn.microsoft.com/en-us/library/ms731325.aspx http://forums.silverlight.net/forums/p/88704/205040.aspx
<强>更新强>
您可以尝试按照此处所述增加<binaryMessageEncoding />
:
http://social.msdn.microsoft.com/Forums/en/wcf/thread/e6e21132-ad3f-4135-8ab9-77923b099907
答案 1 :(得分:1)
也许你的XElement有太多节点/子元素,你需要将dataContractSerializer下的maxItemsInObjectGraph属性设置为更大的值吗?
答案 2 :(得分:1)
尝试将以下代码段添加到服务应用程序的web.config中:
<system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>
在Web服务器中托管服务时,还必须调整Web服务器的允许请求大小。
祝你好运, 拉吉斯拉夫
答案 3 :(得分:0)
你知道如何关闭VS主机并只是部署到IIS并给它一个ping。你的开发盒上的普通IIS 7就可以了。你仍然可以附加调试器等,只是不会有即时的F5满足,但由于你的ocode没有在启动时死亡,你不需要看看是否从第一行:-)
如果你需要很早地附加,你可以制作一个根本没有任何东西的mimimal方法,只返回int constnat - 只是为了调出应用程序池以便你可以附加。