I have to select specific node from the WCF request OperationContext.Current.RequestContext.RequestMessage.ToString()
The problem is that namespaces are changeing prefixes between requests:
So once it is:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<s:Body>
</s:Body>
</s:Envelope>
and other time it is:
<soapenv:Envelope xmlns:mes="MessageContracts" xmlns:req="RequestMessages" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
</soapenv:Body>
</soapenv:Envelope>
How can I assure that I always get Body node correctly?
It doesn’t matter what the prefixes are as long as the nodes are using the same namespace consistently (which they are in your example). You just need to make sure that you create a prefix->namespace mapping for the namespace correctly when you do your selection:
The following code should work as-is for both of your example xmls:
Working ideone example