Reputation: 47
I'm having a little trouble with my service. It does not support a large amount of data, and I have to send an image encoded in base64 for it. The service configuration is like this:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "create", BodyStyle = WebMessageBodyStyle.Bare)]
WSResult<WebService.Model.Order> create(WSOrderCreateParams paramsData);
And the web.config has this configurations:
<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>
Can anyone help me?
Upvotes: 2
Views: 214
Reputation: 47
I've solved it, by the web config. This is how the Web.config is now:
<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>
I've added the bindingConfiguration at the service, like @kei said, and
<serverRuntime uploadReadAheadSize="2147483647" />
at system.webServer. The default pool of IIS won't let you use the uploadReadAheadSize, so you have to go on : IIS Manager > Configurations Editor > Section: system.webServer/serverRuntime > Unlock Section. Doing this, it should work :)
Upvotes: 1