String too long for WCF
I am trying to send a long WCF string about 64k characters long. When I post a long string, I get an HTTP 400 error. But when I post a shorter string, everything works fine. Here is the WCF frontend and app.config that I am using.
My post contract:
[MessageContract]
public class MessageClass
{
[MessageHeader(MustUnderstand = true)]
public string id;
[MessageBodyMember(Order=1)]
public string realMessage; // Long string
}
I tried to change my app.config settings by raising the values:
<bindings>
<basicHttpBinding>
<binding
name="ws"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="10067108864">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
Is there any other value I should change?
source to share
You also need to set "maxBufferSize" and "maxBufferPoolSize" in your binding:
<bindings>
<basicHttpBinding>
<binding
name="ws"
transferMode="Streamed"
messageEncoding="Mtom"
maxReceivedMessageSize="10067108864"
maxBufferSize="500000" maxBufferPoolSize="500000">
<readerQuotas
maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
Same as standard WCF bindings, defaults to 64KB. However, since you are using "transferMode = Streamed", this should really not be a problem - there may be something going on there. How about increasing the parameter sendTimeout
? Perhaps your service is simply taking too long to respond.
Mark
source to share
See the maxReceivedMessageSize attribute of the basicHttpBinding @ http://msdn.microsoft.com/en-us/library/ms731361.aspx element . Coindicentally, default 65,536 KB.
source to share