locked
Debatch a message of multiple message types RRS feed

  • Question

  • Hi,

    How can we debatch a message containing multiple message type ( e.g. purchase order, sales order, invoice)  into individual messages in an orchestration.

    Regards,

    Sharmishtha

    Thursday, November 29, 2018 12:57 PM

Answers

  • HOLD ON!

    Don't over think this.  In most cases...you just do.  Meaning, there's no difference between debatching out one type of message vs multiple types.

    Presuming a consistent Envelope structure, you just need a valid Schema for each Document Type contained in the Envelope.  Meaning...

    <MyEnvelope>
     <SalesOrder/>
     <Invoice/>
     <ShipNotice/>
    </MyEnvelope>
    

    Works out of the box, no problem.  You just add the multiple Document Specs in the XmlDisassembler.

    • Proposed as answer by El Bo Thursday, November 29, 2018 2:42 PM
    • Marked as answer by Sharmishtha Friday, November 30, 2018 1:15 PM
    Thursday, November 29, 2018 1:54 PM
    Moderator

All replies

  • Hi,

    I am not sure how you are receiving this message inside orchestration?

    If you are able to receive then inside orchestration you can try below things

    1. Set TargetNamespace

    Make sure all your schemas has appropriate TargetNamespace, in general its very important to have a TargetNamespace, because BizTalk identifies the message based on the combination of TargetNamespace#RootElement combination.

    2. We need to include namespaces in the XPath.

    Any XPATH we use inside the orchestration must be fully qualified with the local name and namespace uri (TargetNamespace we set in the schemas) as shown below.

    nRecordCount = System.Convert.ToInt32(xpath(Input, “count(/*[local-name()=’EnvelopeData’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’]/*[local-name()=’Data’and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’])”));

    3. When looping through the nodes, we need to use xpaths node-set function position() .

    When we are extracting the sub message from the envelope message we’ll be extracting it based on the position inside a loop. We can make use of XPATH Node-set function position() to get to the sub message as shown below

    sXPath = System.String.Format(“/*[local-name()=’EnvelopeData’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’]/*[local-name()=’Data’ and namespace-uri()=’http://www.digitaldeposit.net/samples/schemas’ and position()={0}]”, nLoopCount);

    4. Set Schemas “ElementFormDefault” property to Qualified (default is unqualified)

    When elementFormDefault is set to qualified, it implies that all the elements must be explicitly qualified, either by using a prefix or setting a {default namespace}. An unqualified setting means that only the globally declared elements must be explicitly qualified, and the locally declared elements must not be qualified. Unfortunately the default setting for elementFormDefault is unqualified.

    If you don’t set the elementFormDefault value to Qualified the output will be as shown below without any values.

    <?xml version=”1.0″ encoding=”utf-8″?>
    < ns0:MappedData xmlns:ns0=”
    http://www.digitaldeposit.net/samples/schemas”>
    < Id></Id>
    < Company></Company>
    < FName></FName>
    < LName></LName>
    < OrderId></OrderId>
    < RecDate></RecDate>
    < ShipDate></ShipDate>
    < /ns0:MappedData>

    Once after setting the elementFormDefault to Qualifed, you’ll get the required output.

    <?xml version=”1.0″ encoding=”utf-8″?>
    < ns0:MappedData xmlns:ns0=”
    http://www.digitaldeposit.net/samples/schemas”>
    < ns0:Id>3</ns0:Id>
    < ns0:Company>City Power And Light</ns0:Company>
    < ns0:FName>Greg</ns0:FName>
    < ns0:LName>Chapman</ns0:LName>
    < ns0:OrderId>12031-ABC-0001</ns0:OrderId>
    < ns0:RecDate>5/15/2005</ns0:RecDate>
    < ns0:ShipDate>5/17/2005</ns0:ShipDate>
    < /ns0:MappedData>

    Regards,

    Sharad

    Thursday, November 29, 2018 1:14 PM
  • But the best approach is to do it inside pipeline you will have much better control and performance.
    Thursday, November 29, 2018 1:15 PM
  • Hi,

    Whether or whether not you have TargetNamespace inside orchestration you can achive this using XSLT and XPATH(Refer Link#1)

    Link#1 https://blogs.biztalk360.com/message-debatching-inside-biztalk-orchestration-with-targetnamespace/

    HTH


    Hope this Helps!!!! Regards, Note: Please Mark As Answered if you satisfy with Reply.

    Thursday, November 29, 2018 1:16 PM
  • HOLD ON!

    Don't over think this.  In most cases...you just do.  Meaning, there's no difference between debatching out one type of message vs multiple types.

    Presuming a consistent Envelope structure, you just need a valid Schema for each Document Type contained in the Envelope.  Meaning...

    <MyEnvelope>
     <SalesOrder/>
     <Invoice/>
     <ShipNotice/>
    </MyEnvelope>
    

    Works out of the box, no problem.  You just add the multiple Document Specs in the XmlDisassembler.

    • Proposed as answer by El Bo Thursday, November 29, 2018 2:42 PM
    • Marked as answer by Sharmishtha Friday, November 30, 2018 1:15 PM
    Thursday, November 29, 2018 1:54 PM
    Moderator