I am having trouble retrieving the body from a wcf message. I am trying to implement a WCF message inspector to check messages using the XSD scheme.
The body of the soap is as follows:
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Header xmlns="http://www.test1.com"> <applicationID>1234</applicationID> </Header> <GetMatchRequest xmlns="http://www.tempuri.org">test</GetMatchRequest> </s:Body>
The problem is that when I try to get the body, it only receives a partial message from the body. Gets only the title element, ignores the GetMatchRequest element (maybe due to multiple namespaces ...)
I use the following to get the message body:
XmlDocument bodyDoc = new XmlDocument(); bodyDoc.Load( message.GetReaderAtBodyContents().ReadSubtree());
I also tried the following:
bodyDoc.Load( message.GetReaderAtBodyContents());
The above code results in an error. This document already has a "DocumentElement" node.
Can anyone help in extracting the body from the WCF message?
thanks
source share