I am using a WCF client to call a JAX web service.
When the response is deserialized, an array within the response object is always empty. However, if I mannually add the namespace to the array type within the response using a message inspector, the response is deserialized correctly.
So the response I get is:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<S:Body>
<ns2:myResponse xmlns:ns2="http://mynamespace.com/">
<myArray>
<myObject>
<myString>abcde</myString>
<myInt>12345</myInt>
</myObject>
</myArray>
<id>7777</id>
</ns2:myResponse>
</S:Body>
</S:Envelope>
and this will produce an object of type myResponse, with the correct 'id' feild but an empty array of type myObject for the myArray field.
When I manually edit the recieved message to add the namespace alias 'ns2' before the myObject tags, so that it looks like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" />
<S:Body>
<ns2:myResponse xmlns:ns2="http://mynamespace.com/">
<myArray>
<ns2:myObject>
<myString>abcde</myString>
<myInt>12345</myInt>
</ns2:myObject>
</myArray>
<id>7777</id>
</ns2:myResponse>
</S:Body>
</S:Envelope>
the correct object is deserialized ie with a myArray of size 1 containing the correct myObject.
Can anyone tell me why this is and how I can get the WCF deserialization to work correctly without manual intervention?
Not sure if this is exactly your problem, but may be worth a try.
We had a similar problem. In our case there was a complex object that was being deserialized with several fields missing. Using a debugger we could see that the information was there. But we could not get to it through the code.
What worked for us was to cast the object to a type that included all the fields.
Check your references.cs file, which datatypes are defined there?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With