我的服务有点麻烦。它不支持大量数据,我必须为它发送一个用base64编码的图像。 服务配置如下:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "create", BodyStyle = WebMessageBodyStyle.Bare)]
WSResult<WebService.Model.Order> create(WSOrderCreateParams paramsData);
web.config有这样的配置:
<system.web>
<compilation targetFramework="4.5" debug="true" />
<httpRuntime targetFramework="4.5" maxRequestLength="1000000000"/>
<system.web>
...
<service.serviceModel>
...
<webHttpBinding>
<binding name="WebHttpEndpointBinding"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</webHttpBinding>
...
</service.serviceModel>
...
<services>
<service name="WebService.ws.Order">
<endpoint address="" behaviorConfiguration="Web" binding="webHttpBinding" contract="WebService.ws.IOrder"/>
</service>
</services>
任何人都可以帮助我吗?
答案 0 :(得分:1)
我已经通过网络配置解决了这个问题。这就是Web.config现在的方式:
<system.web>
<compilation targetFramework="4.5" debug="true" />
<httpRuntime targetFramework="4.5" maxRequestLength="1000000000"/>
<system.web>
...
<service.serviceModel>
...
<webHttpBinding>
<binding name="WebHttpEndpointBinding"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"/>
</security>
</binding>
</webHttpBinding>
...
</service.serviceModel>
...
<services>
<service name="WebService.ws.Order">
<endpoint address="" bindingConfiguration="WebHttpEndpointBinding" behaviorConfiguration="Web" binding="webHttpBinding" contract="WebService.ws.IOrder"/>
</service>
</services>
...
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
<serverRuntime uploadReadAheadSize="2147483647" />
</system.webServer>
我在服务中添加了bindingConfiguration,就像@kei说的那样,和
<serverRuntime uploadReadAheadSize="2147483647" />
在system.webServer上。 IIS的默认池不允许您使用uploadReadAheadSize,因此您必须继续:IIS管理器&gt;配置编辑器&gt;部分:system.webServer / serverRuntime&gt;解锁部分。这样做,它应该工作:)