none
Debatching xml file RRS feed

  • Question

  • Hello people,

    my question would look simple but I really need any advise/suggestion on this scenario please. I have tried looking for debatching schemas which is worked fine but with this one I'm unable to.

    I'm receiving an idoc(ZDELVRY07) from SAP system and mapping that to an xml message and the output looks like below.

    <?xml version="1.0" encoding="utf-8"?>
    <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">
      <PurchaseOrder>
             <Date></Date>
              ....... other elements go here
           <Order1>
                      <Number></Number>
                       .........other elements go here
        </Order1>
        <Order2>
                      <Number></Number>
                       .......other elements go here
        </Order2>
        <Order3>
                      <Code></Code>
                       ........ other elements go here
        </Order3>
      </PurchaseOrder>

    ...... other <PurchaseOrder> records go here like below

    <PurchaseOrder></PurchaseOrder>

    </PurchaseOrder></PurchaseOrder>

    </ns0:PurchaseOrder>

    So in the above xml file there will be multiple records of <PurchaseOrder> and each record of these needs to be generated as an individual message for which I'm trying Debatching.

    I have created an envelope schema. Created a receive Location, selected XML Receive Pipeline and set the documentspec name and Envelope schema properties on xml receive pipeline. Now while testing  the first map gets executed which is to transform IDOC message to xml message from one receive port and its location and that message is above shown one and then trying to pick up this xml message from another receive location where envelope properties are set but getting error like below.

    Error:

    A message received by adapter "FILE" on receive location "Receive Location4" with URI "C:\Test\*.xml" is suspended. 
     Error details: There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.XMLReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Source: "XML disassembler" Receive Port: "ReceivePort4" URI: "C:\Test\*.xml" Reason: Document type "PurchaseOrder" does not match any of the given schemas.

    Is anyting missing here? Should the xml message generated be mapped again  to get into Envelope message whcih then is identified by XML receive pipeline to debatch the message? Not sure.. Can anyone please suggest how i can get this resolved? 

    Your prompt response is of great help please.. 

    Tuesday, November 1, 2016 11:41 PM

Answers

  • Hi Yashod

    What is happening is that after debatching, the following XML is getting generated-

    <PurchaseOrder>
             <Date></Date>
              ....... other elements go here
           <Order1>
                      <Number></Number>
                       .........other elements go here
        </Order1>
        <Order2>
                      <Number></Number>
                       .......other elements go here
        </Order2>
        <Order3>
                      <Code></Code>
                       ........ other elements go here
        </Order3>
      </PurchaseOrder>

    Note that this does not contain the outer PurchaseOrder node-

    <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">

    You don't have a schema defined/deployed for the first XML without the namespaces, and hence it is failing.

    What you can do is deploy a schema for the debatched XML and it will work fine. Note that this schema will not contain a namespace for the root PurchaseOrder element. This would be a perfectly valid schema as well, you can read on this here. You can simply take the debatched XML output and generate the schema from it in Visual Studio.


    Thanks Arindam



    Wednesday, November 2, 2016 3:53 AM
    Moderator
  • As I recall, SAP Schemas are not generated using any relationships.  Meaning, the Adapter Wizard has no idea that the SAP output is really a 'batch' of PurchaseOrder entities.  So, the Schema is not setup to represent both the batch, <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">, and individual entities, <PurchaseOrder>.

    Is that correct, by the way?  It's highly unusual that the both would be named PurchaseOrder?  Especially from SAP.

    The easiest way to correct this would be:

    1. Copy the .xsd and correct the filename and Typename.
    2. Move <PurchaseOrder> to the root level a delete the other one.
    3. Remove the TargedNamespace.
    4. Deploy and try again.

    The reason is you need both Schemas deployed.

    Wednesday, November 2, 2016 11:52 AM
  • Hi,

    Check this article written by Johns:

    http://social.technet.microsoft.com/wiki/contents/articles/32744.biztalk-preserve-xml-header-when-debatching.aspx


    Regards PK: Please mark the reply as answer or vote it up, as deemed fit.

    Thursday, November 3, 2016 3:59 PM
  • Hi,

    check if the destination schema in your first map is deployed.  Look into bt admin console > schema - the following one .

    http://Test.Schemas.PurchaseOrder#purchaseorder 


    Regards PK: Please mark the reply as answer or vote it up, as deemed fit.



    Wednesday, November 2, 2016 1:53 AM

All replies

  • Hi,

    check if the destination schema in your first map is deployed.  Look into bt admin console > schema - the following one .

    http://Test.Schemas.PurchaseOrder#purchaseorder 


    Regards PK: Please mark the reply as answer or vote it up, as deemed fit.



    Wednesday, November 2, 2016 1:53 AM
  • Hi Yashod

    What is happening is that after debatching, the following XML is getting generated-

    <PurchaseOrder>
             <Date></Date>
              ....... other elements go here
           <Order1>
                      <Number></Number>
                       .........other elements go here
        </Order1>
        <Order2>
                      <Number></Number>
                       .......other elements go here
        </Order2>
        <Order3>
                      <Code></Code>
                       ........ other elements go here
        </Order3>
      </PurchaseOrder>

    Note that this does not contain the outer PurchaseOrder node-

    <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">

    You don't have a schema defined/deployed for the first XML without the namespaces, and hence it is failing.

    What you can do is deploy a schema for the debatched XML and it will work fine. Note that this schema will not contain a namespace for the root PurchaseOrder element. This would be a perfectly valid schema as well, you can read on this here. You can simply take the debatched XML output and generate the schema from it in Visual Studio.


    Thanks Arindam



    Wednesday, November 2, 2016 3:53 AM
    Moderator
  • Hi Arindam,

    Thanks for your response. The xml i have given in my case is the one which is generated as part of idoc mappings i.e. 1st mapping. Then i need to pick that xml and debatch  for getting individual Purchase order records. So if you could let me know how i could debatch the xml i have given  above should work fine right? or if you could let me know the steps to debatch the xml i have given above? 

    thanks again..

    Wednesday, November 2, 2016 9:01 AM
  • Hi Yashod

    I would suggest to deploy/create a 2nd schema that corresponds to the debatched message, so that the debatched messages can be published. Basically you can copy the current PurchaseOrder schema and remove the Target Namespace value in the Schema properties. This can serve as the schema for the debatched message.

    <PurchaseOrder>
             <Date></Date>
              ....... other elements go here
           <Order1>
                      <Number></Number>
                       .........other elements go here
        </Order1>
        <Order2>
                      <Number></Number>
                       .......other elements go here
        </Order2>
        <Order3>
                      <Code></Code>
                       ........ other elements go here
        </Order3>
      </PurchaseOrder>

    This way, you don't have to go for custom debatching - like adding the namespace and so on on the root node.

    It is very simply to try out - please refer my earlier post.


    Thanks Arindam


    Wednesday, November 2, 2016 9:23 AM
    Moderator
  • Hi Yashod,

    you can use orhcestration for debatching . 

    refer below link :

    http://geekswithblogs.net/sthomas/archive/2005/06/16/44023.aspx

    Regards

    Abhay Giri

    Wednesday, November 2, 2016 11:24 AM
  • As I recall, SAP Schemas are not generated using any relationships.  Meaning, the Adapter Wizard has no idea that the SAP output is really a 'batch' of PurchaseOrder entities.  So, the Schema is not setup to represent both the batch, <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">, and individual entities, <PurchaseOrder>.

    Is that correct, by the way?  It's highly unusual that the both would be named PurchaseOrder?  Especially from SAP.

    The easiest way to correct this would be:

    1. Copy the .xsd and correct the filename and Typename.
    2. Move <PurchaseOrder> to the root level a delete the other one.
    3. Remove the TargedNamespace.
    4. Deploy and try again.

    The reason is you need both Schemas deployed.

    Wednesday, November 2, 2016 11:52 AM
  • Hi All,

    Thanks for all your responses. I got the Debatching working correctly now. 

    I want to retain the header information for each debatched messages. Like my schema should be below..

    <?xml version="1.0" encoding="utf-8"?>
    <ns0:PurchaseOrder xmlns:ns0="http://Test.Schemas.PurchaseOrder">

    <Record>

    <HeaderText>

    <Po Number>

    ... other elements 

      <Order1>
                      <Number></Number>
                       .........other elements go here
        </Order1>

    </Record>

    </ns0:Purchase Order>

    with each debatced Order1 message i need to include the hearder information which is under Record. How can I include this header information? 

    Any suggestions please?

    Thursday, November 3, 2016 3:22 PM
  • Hi,

    Check this article written by Johns:

    http://social.technet.microsoft.com/wiki/contents/articles/32744.biztalk-preserve-xml-header-when-debatching.aspx


    Regards PK: Please mark the reply as answer or vote it up, as deemed fit.

    Thursday, November 3, 2016 3:59 PM