public static Message CreateWCFMessage(SoapMessageBase message, string action) { if (message == null) { return(null); } return(CreateWCFMessage(message.SoapEnvelopeVersion, message.WSAddressingVersion, action, message.SoapEnvelopeBodyContent)); }
public static void ParseWCFMessage(SoapMessageBase message, Message wcfMsg) { if (message == null || wcfMsg == null || wcfMsg.Version == null) { return; } message.SoapEnvelopeVersion = GetSoapEnvelopeVersion(wcfMsg.Version.Envelope); message.WSAddressingVersion = GetWSAddressingVersion(wcfMsg.Version.Addressing); using (MemoryStream ms = new MemoryStream()) { using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateTextWriter(ms, Encoding.UTF8)) { wcfMsg.WriteBodyContents(xw); //it can automatically handle xml namespace, such as moving the necessary namespace declaration from envelope to body content. xw.Close(); } string str = Encoding.UTF8.GetString(ms.GetBuffer()); ms.Close(); message.SoapEnvelopeBodyContent = str.TrimEnd('\0'); } }