gpt4 book ai didi

由于参数大小导致 WCF 服务通信异常

转载 作者:行者123 更新时间:2023-12-04 20:36:23 25 4
gpt4 key购买 nike

我有一个 WCF Web 方法,它将 XElement 对象作为参数。对于我的一个 XML 文件(大小为 600KB 左右),这工作得很好,但是,对于这个更大的 XML 文件(大约 5MB),我立即得到一个 CommunicationException。

我已经增加了绑定(bind)的消息大小。下面是我的 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>

提前致谢!

最佳答案

尝试将以下代码段添加到服务应用程序的 web.config 中:

  <system.web>
<httpRuntime maxRequestLength="16384" /> <!-- 16MB -->
</system.web>

当您在 Web 服务器中托管服务时,您还必须调整 Web 服务器允许的请求大小。

最好的祝福,
拉迪斯拉夫

关于由于参数大小导致 WCF 服务通信异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3426490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com