Pol*_*431 14 wcf maxstringcontentlength
我需要将maxStringContentLength更改为大于8192的值但尚未成功执行此操作.如果收到的数据量大于8192字节,我的WCF服务将生成异常.我已经用尽了我的搜索,似乎没有任何帮助.我应该指出异常来自服务器.忘记客户端,因为我看到直接从服务器上的WCF生成的异常.这是我的web.config设置:
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="DevServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="DeveloperService"
behaviorConfiguration="DevServiceBehavior" >
<endpoint address="mtom"
binding="basicHttpBinding"
bindingConfiguration="Binding_DevService"
contract="DeveloperService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint contract="IMetadataExchange"
binding="mexHttpBinding"
address="mex" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="Binding_DevService"
messageEncoding="Mtom"
openTimeout="00:02:00"
sendTimeout="00:02:00"
maxBufferPoolSize ="41943040"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="500"
maxArrayLength="20000000"
maxStringContentLength="20000000" />
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
Pol*_*431 19
默认情况下,最新版本的WCF确实设置默认值,json是默认值.不清楚的是WCF使用什么样的默认绑定.原来是webHttpBinding.您还将在Web上看到大量示例,其中显示了应用于服务方法的属性,例如[WebGet].该方法根本不需要任何属性.要使maxStringContentLength生效,您需要正确设置绑定和行为.以下是web.config文件中的正确条目:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="DevServiceBehavior" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="DeveloperService" behaviorConfiguration="DevServiceBehavior" >
<endpoint address="" binding="webHttpBinding" contract="DeveloperService" bindingConfiguration="webHttpBindingDev" behaviorConfiguration="jsonBehavior">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webHttpBindingDev">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33529 次 |
| 最近记录: |