Quantcast
Channel: Geekswithblogs.net
Viewing all articles
Browse latest Browse all 6441

Creating a custom BizTalk 2010 pipeline component–Part 3

$
0
0

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;
}


Viewing all articles
Browse latest Browse all 6441