1

Below Xml Format I want to deserialize into C# Object.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <GetImagesByAssetResponse xmlns="http://tempuri.org/">
            <GetImagesByAssetResult>
                <anyType xsi:type="xsd:string">"Hello"</anyType>
                <anyType xsi:type="xsd:string">"Test"</anyType>
                <anyType xsi:type="xsd:string">"Test 3"</anyType>
            </GetImagesByAssetResult>
        </GetImagesByAssetResponse>
    </soap:Body>
</soap:Envelope>

And I'm using code to deserialize above soap xml int c# class object

var rawXML = XDocument.Parse(soapResponse);
                    Envelope deserializedObject;
                    using (var reader = rawXML.CreateReader(System.Xml.Linq.ReaderOptions.None))
                    {
                        var ser = new XmlSerializer(typeof(Envelope));
                        deserializedObject = (Envelope)ser.Deserialize(reader);
                    }

Here i'm getting the exception every time.

There is an error in XML document (0, 0).

And Inner Exception Below

{System.InvalidOperationException: The specified type was not recognized: name='string', namespace='http://www.w3.org/2001/XMLSchema', at http://tempuri.org/'>.

Can anyone please suggest me what i'm missing to parse soap xml?

Pratius Dubey
  • 673
  • 6
  • 19

0 Answers0