Integrating Integrators – BizTalk, Windows Azure, Windows Workflow, and Beyond

Executing BTAHL7ReceivePipeline in an orchestration

BizTalk 2006

This group is for all content related to BizTalk Server 2006. This includes a forum, samples, videos, labs, and tools. Most of the content here also applies to other versions of BizTalk beyond 2006.

Executing BTAHL7ReceivePipeline in an orchestration

  • rated by 0 users
  • This post has 3 Replies |
  • 1 Follower
  • Hi all:
    I am trying to execute the BTAHL7ReceivePipeline inside an orchestration, the idea is to take a string variable with the HL7 content and convert it to a BTAHL7 message through the pipeline, this is what i am trying:

    HL7Request = new System.Xml.XmlDocument();
    BTAHL7ReceivePipeline = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(BTAHL72XPipelines.BTAHL72XReceivePipeline), HL7Request);
    HL7Request2.MSHSegment = new System.Xml.XmlDocument();
    HL7Request2.BodySegments = new System.Xml.XmlDocument();
    HL7Request2.ZSegments = new System.Xml.XmlDocument();
    Where 'string' contains the HL7 content, 'HL7Request' is a System.String message i pass to the pipeline and 'HL7Request2' is the message i get from the pipeline with the BTAHL7 format.  

    My problem is that when i execute the BTAHL7ReceivePipeline, it says the following error:

    Message has an invalid header, it could be due to error in 1st/2nd field or the segment name is neither MSH nor FHS

    ¿Any idea?

  • Mihai Dan has given me the solution to this problem, here it is:

    The problem when you define your orchestration message as System.String is
    that your message payload is in the following format:
    <?xml version="1.0"?>
    <string>MSH|^~\&|... etc...</string>
    ... which is legitimate considering the message type you have chosen. Same
    with the error message you've got as the HL7 Dasm expects a payload starting
    with MSH or FHS....

    Therefore, the trick is to create xlang message with binary (or string)
    content instead of xml as we usually do.... so, I wrote the following method
    (together with its internal class) that populates my xlang message the way I

    public static void CreateHL7Message(string data, XLANGMessage message)
        message[0].LoadFrom(new HL7StreamFactory(data));


    internal class HL7StreamFactory: IStreamFactory
        private string hl7data = String.Empty;

        public HL7StreamFactory(string hl7data)
            this.hl7data = hl7data;

        public Stream CreateStream()
            return new MemoryStream(ASCIIEncoding.ASCII.GetBytes(hl7data));


    In your MessageAssignment shape the code should look like:
    HL7 = null;
    CreateHL7Message(hl7data, HL7);
    ... where HL7 is the output message (created as XmlDocument) in the

    I hope that my answer reaches you on time... cheers,

    Mihai Dan

  • Hi Mihai Dan,

    With all  appreciation I read your  reply in Biztalk Guru Blog  regarding Executing BTAHL7ReceivePipeline and the resolution  you have suggested  looks like  to  fit my requirement and if is this some thing  you be able to help me and advice how i can proceed further,with your reply I will be looking forward  to.

    Here is my email Contact

    Hope to hear  from you ASAP.

    Expecting you help and appreciate you advice.








  • Issue: Getting HL7 data via SOAP and sending to HL7 Receive pipeline by extracting string HL7 data from SOAP XML and calling the custom pipeline (pipeline with custom data formatting routine to format line breaks etc and passing to HL72x DASM).

    I am keep getting the error executing the object reference not set errof when calling GetCurrent(msgQBP) -- see below for code. Any thoughts what would cause it? Below is the code that I am using.


    InputPipeline = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(HL7SourceQBPRecvPipeline), msgImmunizationHistoryResponse);


    msgQBP.MSHSegment = new System.Xml.XmlDocument();

    msgQBP.BodySegments = new System.Xml.XmlDocument();

    msgQBP.ZSegments = "";



    Any help would be appriciated.



Page 1 of 1 (4 items)