singhhome

I want to serialize the result of my operation as a JSON format. As per MSDN sample I have removed the DataContractSerailizer and inserted my custome formatter. But trying to DeserailzeReply gives an exception "Maximum string quota exceeded. use MaxStringContextLength property".

How do I read and set content length property for reading Message body

How should i create the message in IDispatchMessageFormatter.SerializeReply how to read message in

IClientMessageFormatter.DeserializeReply

In SerializeReply

Message.CreateMessage(messageVersion, action, new JsonMessageWriter(jsonstring))

//JsonMessageWriter

JsonMessageWriter : BodyWriter

{

override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
{
writer.WriteString(this.jsonData);
writer.Flush();
}

}

In DeSerializeReply

XmlDictionaryReader reader = message.GetReaderAtBodyContents();
string data = reader.ReadContentAsString();

Regards,




Re: Windows Communication Foundation (Indigo) Custome Formatter

Brian McNamara - MSFT

MaxStringContentLength is a property on XmlDictionaryReaderQuotas, which is available from the ReaderQuotas property on the binding (or MessageEncodingBindingElement in a CustomBinding). So configure this knob on the binding and you should be good to go there.

As for the Messages, the code you have looks ok offhand.






Re: Windows Communication Foundation (Indigo) Custome Formatter

singhhome

Thnaks, but how do i get "binding" for setting ReaderQuotas I am not using custom bindnig but basicHttpBinding

I could not fing MaxStringContentLength in <bindings/> in the config file.

Regards,






Re: Windows Communication Foundation (Indigo) Custome Formatter

Brian McNamara - MSFT

I am not at work now, so I don't have intellisense/config schema, but from memory, I think it is like...

... in service or client...

<endpoint address=blah binding="basicHttpBinding" bindingConfiguration="MyBetterQuotas" contract=blah ...>

... and then ...

<bindings>

<basicHttpBinding>

<binding name="MyBetterQuotas">

<readerQuotas maxStringContentLength="999999" />

</binding>

</basicHttpBinding>

</bindings>