【发布时间】:2023-03-23 06:44:01
【问题描述】:
我找不到这个问题的答案。大多数类似的帖子似乎都可以通过调整 web.config 文件中的一些最大大小设置来修复。但是,这些建议都没有解决我的问题。
为了提供更多背景知识,我将 asmx Web 服务移植到 Windows Azure 中托管的 WCF Web 服务。这个问题是在测试过程中出现的。如果我在一次调用中将少量事务传递给我的网络服务,它往往工作得很好。虽然当我的事务大小达到 50-60(事务)左右时,会出现此错误。序列化为 xml,文件大小在 300K 左右,所以没什么大不了的。但它确实倾向于尺寸问题。
另外,打开 WCF 跟踪,我发现出现以下异常:
System.ServiceModel.ProtocolException:已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。
在 System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
在 System.ServiceModel.Channels.HttpInput.ThrowMaxReceivedMessageSizeExceeded()
在 System.ServiceModel.Channels.HttpInput.ReadBufferedMessage(Stream inputStream)
在 System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException)
在 System.ServiceModel.Channels.HttpChannelListener.HttpContextReceived(HttpRequestContext 上下文,动作回调)
因此,从例外情况来看,它看起来好像是我的 web.config 中关闭的设置之一,但它看起来像这样:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
<behavior name="MetadataEnabled">
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceMetadata httpGetEnabled="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="http" port="8081"/>
<add scheme="https" port="444"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
<dataContractSerializer maxItemsInObjectGraph="111024000"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Bandicoot.Core" behaviorConfiguration="MetadataEnabled">
<endpoint name="HttpEndpoint"
address=""
binding="wsHttpBinding"
bindingConfiguration="wsHttp"
contract="Bandicoot.CORE.IRepricer" />
<endpoint name="HttpMetadata"
address="contract"
binding="mexHttpBinding"
bindingConfiguration="mexBinding"
contract="Bandicoot.CORE.Stack" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/Core"/>
</baseAddresses>
</host>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttp" maxReceivedMessageSize="111024000"
messageEncoding="Text" maxBufferPoolSize="111024000"
textEncoding="UTF-8">
<readerQuotas maxBytesPerRead="111024000"
maxArrayLength="111024000"
maxStringContentLength="111024000"/>
<security mode="None"/>
</binding>
</wsHttpBinding>
<mexHttpBinding>
<binding name="mexBinding"/>
</mexHttpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
有没有人有任何其他建议,或者我的 web.config 中是否有一些我没有看到的错误配置?
感谢您的建议!
编辑:这是我客户的 app.config 中的设置
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_CORE" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="14194304" maxBufferPoolSize="14194304" maxReceivedMessageSize="14194304"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="1000" maxStringContentLength="111024000"
maxArrayLength="111024000" maxBytesPerRead="1024000" maxNameTableCharCount="111024000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
编辑:添加附加客户信息:
<client>
<endpoint address="http://localhost:92/CORE.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_CORE" contract="Core.CORE"
name="BasicHttpBinding_CORE" />
</client>
编辑:尝试将服务绑定更改为 basicHttpBinding - 配置更改:
<basicHttpBinding>
<binding name="basicHttp" maxReceivedMessageSize="111024000"
messageEncoding="Text" maxBufferPoolSize="111024000"
textEncoding="UTF-8">
<readerQuotas maxArrayLength="111024000" maxBytesPerRead="111024000" maxStringContentLength="111024000"/>
<security mode="None" />
</binding>
</basicHttpBinding>
<service name="Bandicoot.Core" behaviorConfiguration="MetadataEnabled">
<endpoint binding="basicHttpBinding"
bindingConfiguration="basicHttp"
contract="Bandicoot.CORE.IRepricer" />
<endpoint address="mex"
binding="mexHttpBinding"
bindingConfiguration="mexBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/Core"/>
</baseAddresses>
</host>
</service>
还有客户端的 app.config 供参考:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_CORE" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="100000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:92/CORE.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_CORE" contract="Core.CORE"
name="BasicHttpBinding_CORE" />
</client>
【问题讨论】:
-
您的客户端端点是否真的使用这些设置??
-
您的服务定义了一个
wsHttpBinding- 您的客户有basicHttpBinding的设置......那些甚至匹配吗?另外 - 你没有向我们展示你客户配置的<client>...</client>部分 - 这将是最有趣的! -
@marc_s - 此客户端配置的大部分只是由 Visual Studio 中的“添加服务引用”功能自动生成的。由于我们的客户将使用此 Web 服务,如果他们不需要破解配置文件以使我们的服务正常工作,那将是更好的选择......这可能是它自己的另一个问题,所以现在我只想得到它工作。我已经发布了我的配置文件的客户端部分。如果您看到任何看起来不正确的内容,请告诉我。谢谢!
-
有谁知道是否有办法确认服务器端实际使用的是什么绑定?
标签: asp.net wcf web-config azure