nover
nover

Reputation: 2369

ServiceStack SOAP XmlException: The input document has exceeded a limit set by MaxCharactersInDocument

As the title suggest, we are currently struggling with a ServiceStack v 4.0.44 SOAP service that throws the exception (full stacktrace here)

XmlException: The input document has exceeded a limit set by MaxCharactersInDocument.
... stacktrace cut down for brewity ... 
File "ServiceStack.Text.XmlSerializer" line 33 in Deserialize(System.String xml, System.Type type)
File "ServiceStack.Serialization.DataContractSerializer" line 34 in DeserializeFromString(System.String xml, System.Type type)
File "ServiceStack.Host.Handlers.SoapHandler" line 266 in ExecuteMessage(System.ServiceModel.Channels.Message message, ServiceStack.RequestAttributes requestAttributes, ServiceStack.Web.IRequest httpReq, ServiceStack.Web.IResponse httpRes)

As far as I can read in other stackoverflow answers, this is a form of protection against XML bombs implemented in .net 4+ ref1 ref2

Now my question is: Is it possible to override this behavior in SS v4? We are only receiving requests from a trusted source (BizTalk) with data, so as far as I see, it is not a problem disabling this .net safeguard.

Upvotes: 2

Views: 175

Answers (1)

mythz
mythz

Reputation: 143359

You can change the MaxCharactersInDocument the ServiceStack XmlSerialier uses from its current default of:

XmlSerializer.Instance = new XmlSerializer(maxCharsInDocument: 1024 * 1024);

Upvotes: 3

Related Questions