2

I've set up ServiceStack to provide web services for my MVC 4 website. I will only be using Soap1.2 with the web services and so far it's been working well.

Except when I'm trying to send a byte array that's too large after which I get the following error:

The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.

On the client side I've set the readerQuotas for the binding and it seems to pick it up correctly so the problem looks to be on the server side. Normally one would add the binding settings for the web service in the web.config but I'm unsure how to do this for ServiceStack.

That is if it's ServiceStack that's causing the problem.

How would I go about sending a large amount of data to a Soap1.2 web service created with ServiceStack? (Unfortunately by making use of a byte array)

Solitude
  • 31
  • 1
  • 5
  • 1
    Check if this will solve your problem: https://groups.google.com/forum/#!topic/servicestack/4z6ckmKOSRo – cvbarros Feb 26 '14 at 13:16
  • Thanks cvbarros. Do you perhaps have an example of how to set that DataContractSerializer Instance without changing the ServiceStack code? I assume it must be done in the config? I can't seem to set it. – Solitude Feb 26 '14 at 13:29
  • You can simply do this in your application initialization code (bootstrap): `DataContractSerializer.Instance = new DataContractSerializer(new XmlDictionaryReaderQuotas { MaxStringContentLength = /* new value */ };`, effectively setting the singleton instance. – cvbarros Feb 26 '14 at 13:57
  • Excellent! Thanks cvbarros. I added that to the init and also set the MaxArrayLength, MaxBytesPerRead and MaxNameTableCharCount to bigger values (I'll have to play with these values a bit to get them perfect) but it's working now. – Solitude Mar 03 '14 at 07:59
  • @Solitude I am cleaning up some still open but comment-answered questions. I have added cvbarros' answer from comments to the answers section (as community wiki). Please accept this answer so this question can be closed. – Scott May 10 '14 at 09:51

1 Answers1

1

As noted by @cvbarros the value can be specified in the application initialisation code:

DataContractSerializer.Instance = new DataContractSerializer(new XmlDictionaryReaderQuotas
{  
    MaxStringContentLength = /* new value */; 
};
Community
  • 1
  • 1
Scott
  • 21,211
  • 8
  • 65
  • 72