Mix two answers

I ran into a ridiculous issue with serializing WCF responses. After several requests (say 10), WCF starts mixing requests and always after the 128th character when using the Utf8 encoding.

Expected Answer:

<via version="1.1"> <response> <status code="0" /> <res-get-balance> <balance value="38.65" currency="GBP" /> <token>IQV2SSc41Fux6zWeaaUOMKtBvYW3IgtDZFJ4r1</token> </res-get-balance> </response> </via> 

However, I got this as an answer:

 <via version="1.1"> <response> <status code="0" /> <res-get-balance> <balance value="38.65" currency="GBP" /> <token>IQV2SSc41Fux6zWe <via version="1.1"> <response> <status code="0" /> <res-get-balance> <balance value="38.65" currency="GBP" /> <token>IQ 

When it reaches character number 128, it starts from the beginning.

Here is my binding configuration:

 <webHttpBinding> <binding name="webHttpBindingConfig" sendTimeout="05:00:00" ></binding> </webHttpBinding> 

Here is my behavior configuration:

 <behavior name="webXmlOverHttpBehavior"> <dataContractSerializer maxItemsInObjectGraph="165536" /> <endpointDiscovery enabled="true" /> <webHttp helpEnabled="true" defaultOutgoingResponseFormat="Xml" /> </behavior> 

My service implementation has the following attribute:

 [ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single)] 

Any ideas?

+1
source share
1 answer

The WCF REST service has a default value and a valid InstanceContextMode instance for PerCall only.

Either it should cause an error when the "InstanceContextMode.Single" parameter is set, or it should ignore it. But he behaves differently.

So uninstall InstanceContextMode and try, it should work.

0
source

All Articles