I hadn’t intended for there to actually be a part 3 to this series, but I realized that I failed to talk about how to get the xml back into the message once you’re done messing with it. You have to convert it to a MemoryStream and assign it to IBaseMessage.BodyPart.Data, like this:
public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg) { IBaseMessagePart bodyPart = inmsg.BodyPart; Stream originalStream = bodyPart.GetOriginalDataStream; if (originalStream!= null) { XmlDocument myXml = new XmlDocument; myXml.Load(originalStream);
myXml = DoWork(myXml); //Whatever you actually want to do to the xml
byte[] outBytes = System.Text.Encoding.ASCII.GetBytes(myXml.OuterXml); MemoryStream memStream = new MemoryStream; memStream.Write(outBytes, 0, outBytes.Length); memStream.Position = 0; bodyPart.Data = memStream; pc.ResourceTracker.AddResource(memStream); }
return inmsg; }
Technorati Tags:
