WCF Web.config maxReceivedMessageSize
我发布了一个包含大量文本的json对象 下面是我当前的WCF Web.config maxReceivedMessageSize,wcf,Wcf,我发布了一个包含大量文本的json对象 下面是我当前的web.config。我应该如何修改以将消息大小更改为发布大json 这是紧急情况,请尽快回复。谢谢 <?xml version="1.0"?> <configuration> <appSettings> <add key="LogPath" value="\Logs\" /> </appSettings> <connectionStri
web.config
。我应该如何修改以将消息大小更改为发布大json
这是紧急情况,请尽快回复。谢谢
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="LogPath" value="\Logs\" />
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<httpRuntime maxRequestLength="10000" />
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<client>
<endpoint address="http://api.microsofttranslator.com/V2/soap.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_LanguageService"
contract="TranslatorService.LanguageService" name="BasicHttpBinding_LanguageService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webby" >
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_LanguageService" 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="65536"
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>
<customBinding>
<binding name="AgricultureTradingWebApp.AgricultureWebService.customBinding0" >
<binaryMessageEncoding />
<httpTransport />
</binding>
</customBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="AgricultureTradingWebApp.AgricultureWebService">
<endpoint address="" binding="customBinding" bindingConfiguration="AgricultureTradingWebApp.AgricultureWebService.customBinding0"
contract="AgricultureTradingWebApp.AgricultureWebService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="json"
binding="webHttpBinding"
contract="AgricultureTradingWebApp.AgricultureWebService"
behaviorConfiguration="webby"/>
</service>
</services>
</system.serviceModel>
</configuration>
看起来您正在使用REST,这是我以前没有做过的,所以可能有一些我不知道的注意事项 但是,json端点使用的是默认的
webHttpBinding
,它的MaxReceivedMessageSize为65536。由于要增加此值,需要定义要在配置文件中使用的webHttpBinding,为其命名,并将该名称分配给json端点的bindingConfiguration属性:
<bindings>
<webHttpBinding>
<binding name="myWebHttpBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="524288" maxBufferPoolSize="524288"
maxReceivedMessageSize="524288"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength=524288"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</webHttpBinding>
</bindings>
<endpoint address="json"
binding="webHttpBinding"
bindingConfiguration="myWebHttpBinding"
contract="AgricultureTradingWebApp.AgricultureWebService"
behaviorConfiguration="webby"/>
你有什么错误吗?您是在客户端(接收响应时)还是在服务器(发送请求时)上获取它们?请求错误。实际上,它更像是524288个字符;根据使用的编码,每个字符可能有1字节,但并不总是如此。我将其视为字节,这是一个普遍的经验法则。