Saturday, 28 February 2015

Trying to Deserialize a SOAP envelope using DataContractSerializer in C#



I've got this working using the XmlSerializer, but wanted to compare performance using the DataContractSerializer. I know I'm close, because I'm at least getting somewhat of an object graph back, but not any data. A sample of XML I'm trying to deserialize looks like this:



<soap-env:Envelope xmlns:soap-env="http://ift.tt/sVJIaE">
<soap-env:Header/>
<soap-env:Body>
<n0:OperationalDataProvisioningFetchDataDirectResponse xmlns:n0="http://sap.com/bw" xmlns:prx="proxy">
<BinaryObject>Binary Data Goes Here</BinaryObject>
<XMLFormatUsedCode>ABAP_XML</XMLFormatUsedCode>
</n0:OperationalDataProvisioningFetchDataDirectResponse>
</soap-env:Body>
</soap-env:Envelope>


My classes to deserialize into look like this:



[DataContract(Name = "Envelope", Namespace = "http://ift.tt/sVJIaE")]
public class Envelope
{
[DataMember(Name = "Header", Order = 0)]
public object Header;

[DataMember(Name = "Body", Order = 1)]
public EnvelopeBody Body;
}

[DataContract(Name = "Body")]
public class EnvelopeBody
{
[DataMember(Name = "OperationalDataProvisioningFetchDataDirectResponse", Order = 0)]
public FetchDataDirectResponse FetchDataDirectResponse;
}

[DataContract(Name = "OperationalDataProvisioningFetchDataDirectResponse")]
public class FetchDataDirectResponse
{
[DataMember(Name = "BinaryObject", Order = 0)]
public string BinaryObject;

[DataMember(Name = "XMLFormatUsedCode", Order = 1)]
public string XMLFormatUsedCode;
}


When I run this and attempt to deserialize this is all i get:


Debugger


No comments:

Post a Comment