简体   繁体   中英

Mix up two responses

I'm facing a funny issue with WCF response serialization. After a number of requests (let's say 10), WCF starts to mix-up requests and always after the 128th character when using Utf8 encoding.

Expected response:

<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 a response:

<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?

For WCF REST service, the default and valid InstanceContextMode is "PerCall" only.

Either it should throw error when "InstanceContextMode.Single" is set, or it should ignore it. But it is behaving differently.

So remove the InstanceContextMode and try, it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM