My solution is to have a wcf service which can accept a pdf/text file streamed as byte array in one of the elements.
I had a BizTalk orchestration exposed as a wcf service. The schema has a content element which is set as xs:base64binary. So the wcf service expects the service consumer to convert the text/pdf document into a byte array and send it to my service. When you expose services which expects one of the element content as byte array, the memory size of the message significanly increases.
You will get the below error when a client sends a bigger file, say 12 mb pdf file.
An error occurred while receiving the HTTP response to http://…….svc.
This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP
request context being aborted by the server (possibly due to the service shutting down). See server logs for more
To troubleshoot this, add wcf tracing in web.config
In the web.config add the below under <configuration> section
initializeData= “c:\log\Traces.svclog” />
Make sure to create the “Log” folder under “C” Drive or feel free to configure a different location to save the logs.
- Use the WCF Trace viewer tool to view the Traces.
a. Open the tool from the path C:\Program files(x86)\Microsoft SDKs\Windows\v7.0A\Bin
b. Open the trace file.
c. You would be able to locate the exception details in the Description pane on the right side.
d. You would see the System.ServiceModel.CommunicationException thrown and the exception message would be “Maximum request length exceeded”
This conforms that the issue we have is related to the request length.
Two things must be done to resolve the issue.
In the BizTalk receive location, set the Maximum receive message size property to 2,147,483,647. This can be found in Adapter properties > Binding section.
In the web.config, add the below line under <system.web> section
<httpRuntime maxRequestLength=”2147483647″ />
Please bear in mind that setting the Maximum value for request length might solve the problem, but this can easily be expolited in case of a DOS attack.