Home Page › Forums › BizTalk 2004 – BizTalk 2010 › BizTalk 2006 R2 WCF-basicHttp adapter configuration – Getting message in service – with null value › Re: BizTalk 2006 R2 WCF-basicHttp adapter configuration – Getting message in service – with null value
Well, for now it seems I will have to work around this issue by converting the message body to a string and manually deserializing it. This works fine and doesn’t add much code, I just don’t think this is the right way to handle it.
My Code (to deserialize to type “X12_00401_271”):
// Convert the message body to a string
StringBuilder stringBuilder = new StringBuilder();
using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stringBuilder))
{
message.WriteBody(writer);
writer.Flush();
}
// Remove the pieces of the string that are causing a deserialization problem (investigate later)
string content = stringBuilder.ToString();
content = content.Replace(“<s:Body xmlns:s=\”http://schemas.xmlsoap.org/soap/envelope/\”>”, string.Empty);
content = content.Replace(“</s:Body>”, string.Empty);
try
{
// Attempt to deserialize the string taken from the message body to an X12_00401_271 object
X12_00401_271 responseMessage = null;
using (StringReader stringReader = new StringReader(content))
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(X12_00401_271));
responseMessage = (X12_00401_271)xmlSerializer.Deserialize(stringReader);
}
// TODO: Do stuff with your object
}
Catch(Exception e)
{
// TODO: Handle exception
}