none
BizTalk Mapping - Singleton Pattern

    Question

  • Input schema

    <?xml version="1.0" encoding="utf-16" ?> 
     <xs:schema xmlns="http://TestMap.InSchema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestMap.InSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="Root">
     <xs:complexType>
     <xs:sequence>
      <xs:element name="InvoiceNo" type="xs:string" /> 
      <xs:element name="City" type="xs:string" /> 
     </xs:sequence>
     </xs:complexType>
     </xs:element>
     </xs:schema>

    I am using Singleton Orch pattern, and my separate invoice instances are merged into 1 like below

    Instances output

    <Test>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>ABD-101</Name> 
    <City>Cairo</City> 
    </ns0:Root>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>BBC-222</Name> 
    <City>NewYork</City> 
    </ns0:Root>
    </Test>
    In next post will be question



    Reason101

    Monday, March 20, 2017 7:06 PM

All replies

  • How can this instances output be mapped to destination schema. Can anyone explain step by step how to deal with this scenario ?

    <?xml version="1.0" encoding="utf-16" ?> 
     <xs:schema xmlns="http://TestMap.Schema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestMap.Schema2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="Root">
     <xs:complexType>
     <xs:sequence>
     <xs:element maxOccurs="unbounded" name="Details">
     <xs:complexType>
     <xs:sequence>
      <xs:element name="InvoiceNo" type="xs:string" /> 
      <xs:element name="City" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>


    Reason101

    Monday, March 20, 2017 7:07 PM
  • You have to wait in Orchestration till you receive all invoices. So you have to make your Orchestration long running. That will cause lot overheads.

    I will go with database approach. You can setup a simple database to store all your invoices. Combine in stored proc and process them after you have received all invoices. This will have long term benefits and you will have full control on your process rather than depending on BizTalk to dehydrate your messages.

    Monday, March 20, 2017 7:16 PM
  • Are you trying to group multiple invoices into a single batch?
    Monday, March 20, 2017 7:27 PM
    Moderator
  • Yes John that is correct, I wanted to group multiple invoices to 1 batch.

    How can I do this ?


    Reason101

    Monday, March 20, 2017 7:33 PM
  • How are you receiving them and exactly what format will they go out it?
    Monday, March 20, 2017 7:52 PM
    Moderator
  • Iam receiving with WCF-SQL Adapter polling in XML format, and my final output will be .csv or XML file as batched. So can this scenario be achieved using XSLT ? Please see Instance output file above

    Reason101




    • Edited by Reason101 Tuesday, March 21, 2017 1:01 AM I
    Monday, March 20, 2017 8:11 PM
  • Hi - below is my XML, how can I create 1 .csv file for this ?

    <Test>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>ABD-101</Name> 
    <City>Cairo</City> 
    </ns0:Root>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>BBC-222</Name> 
    <City>NewYork</City> 
    </ns0:Root>
    </Test>

    Output

    ABD-101, Cairo

    BBC-222,NewYork


    Reason101

    Tuesday, March 21, 2017 1:37 AM
  • Hi ,

    Create a Flat File schema for as per your output using Flat File Schema Wizard and then map the source to the destination schema . At send port you can use Flat File assembler pipeline component to convert xml to CSV.

    Refer the Microsoft documentation below

    https://msdn.microsoft.com/en-us/library/aa577898.aspx 


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply

    Tuesday, March 21, 2017 6:57 AM
  • In addition to what Abhishek has already provided, you have to set Max Occurs property of the Root record to unbounded or *, so that BizTalk does not create multiple messages per occurrence of the Root record.

    Thanks Arindam

    Tuesday, March 21, 2017 8:46 AM
    Moderator
  • What is the batch size? When do you decide to send out the file from the orchestration?

    You can use the Aggregator pattern for this-

    http://geekswithblogs.net/asmith/articles/9778.aspx

    If the messages are large, you can optionally look at-

    http://btsguru.blogspot.in/2011/08/biztalk-aggregation-pattern-for-large.html


    Thanks Arindam

    Tuesday, March 21, 2017 8:53 AM
    Moderator
  • An improved large batch aggregation pattern:

    https://biztalkbox.wordpress.com/2016/08/25/aggregation-pattern-for-large-batches/


    Pi_xel_xar

    Blog: My Blog

    BizTalkApplicationDeploymentTool: BizTalk Application Deployment Tool/

    Tuesday, March 21, 2017 9:06 AM
    Answerer
  • How are the batches bounded?  Shared Value, number of elements, time?
    Tuesday, March 21, 2017 11:34 AM
    Moderator
  • Hi Pi_xel, I am not clear about the approach you guys are mentioning.

    There is source and destination schema, so far I was receiving single invoice so all the mapping logic was implemented for single invoice from source to destination. But now the requirement got changed, I may be receiving multiple invoices so I am thinking of using Aggregation pattern to make this multiple invoice as 1 batch in Orchestration.

    Say after aggregation in Orch, the output will be like

    <Test>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>ABD-101</InvoiceNo> 
    <City>Cairo</City> 
    </ns0:Root>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>BBC-22</InvoiceNo>
    <City>NewYork</City> 
    </ns0:Root>
    <ns0:Root xmlns:ns0="http://TestMap.InSchema"> 
    <InvoiceNo>BBC-333</InvoiceNo> 
    <City>Texas</City> 
    </ns0:Root>
    </Test>

    how can this be mapped as input to destination schema as below

    <?xml version="1.0" encoding="utf-16" ?> 
     <xs:schema xmlns="http://TestMap.Schema2" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestMap.Schema2" xmlns:xs="http://www.w3.org/2001/XMLSchema">
     <xs:element name="Root">
     <xs:complexType>
     <xs:sequence>
     <xs:element maxOccurs="unbounded" name="Details">
     <xs:complexType>
     <xs:sequence>
      <xs:element name="InvoiceNo" type="xs:string" /> 
      <xs:element name="City" type="xs:string" />
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:schema>

    I want the expected output to be

    <Root>
    <ns0:Details xmlns:ns0="http://TestMap.Schema2"> 
    <InvoiceNo>ABD-101</InvoiceNo> 
    <City>Cairo</City> 
    
    <InvoiceNo>BBC-22</InvoiceNo>
    <City>NewYork</City> 
    
    <InvoiceNo>BBC-333</InvoiceNo> 
    <City>Texas</City> 
    </ns0:Details>
    </Root>


    Reason101

    Tuesday, March 21, 2017 11:42 AM