locked
Splitting Message Into Multiple messages RRS feed

  • Question

  • I am receiving a message like

    <EmployeeCollection>

    <Id>0</Id>

    <Company>TTL</Company>

    <Employees>

    <Employee><EmpId>1<EmpId><Name>Ram</Name></Employee>

    <Employee><EmpId>2<EmpId><Name>Vandana</Name></Employee>

    <Employee><EmpId>3<EmpId><Name>Shrestha</Name></Employee>

    </Employees>

    </EmployeeCollection>

    But I have to process each employees separately so I need it to be split like

    <Employee><Id>0</Id><Company>TTL</Company><EmpId>1<EmpId><Name>Ram</Name></Employee>

    <Employee><Id>0</Id><Company>TTL</Company><EmpId>2<EmpId><Name>Vandana</Name></Employee>

    <Employee><Id>0</Id><Company>TTL</Company><EmpId>3<EmpId><Name>Shrestha</Name></Employee>

    I have matching schema both for incoming request(employee collection) and desired schema(employee). But not sure how can I break this into desired format.

    I looked into

    http://social.msdn.microsoft.com/Forums/en-US/6b01a356-1183-4aed-83f2-bd5897413762/split-xml-to-multiple-messages-in-an-orchestration-input-source-from-two-xml-message

    but this think seems to be not working for my scenario (I might be missing something, as there is very little explanation).

    Please advice.

    regards,


    Software Engineer

    Friday, July 5, 2013 11:22 AM

Answers

  • Hi,

    You can use the map in the ReceivePort (or in your orchestration) and you can perform a debatch within the orchestration by executing a receivepipeline, see here.

    Regards

    René

    Friday, July 5, 2013 1:30 PM

All replies

  • Hi

    you can use Xpath Debatching to debatch all Employee records .


    Steps :

    Create Schemas for

    • EmployeeCollection
    • Employee  without id and company  say Emp1
    • Employee  with id and company say Emp2

    promote id and Company from EmployeeCollection schema

    Debatch all employee records from EmployeeCollection

    convert employee  records to schema of type Emp2 .

    assign id and company value from promoted property.

    Regards

    Mohit




    Friday, July 5, 2013 11:47 AM
  • Hi,

    I did tried your scenario and I get the desired ouptut( from what I understood)

    Input :

    <ns0:EmployeeCollection xmlns:ns0="http://TestingSchemas.Employee">
      <Id>Id_0</Id> 
      <Company>Company_0</Company> 
     <Employees>
     <Employee>
      <EmpId>EmpId_0</EmpId> 
      <Name>Name_0</Name> 
      </Employee>
     <Employee>
      <EmpId>EmpId_1</EmpId> 
      <Name>Name_1</Name> 
      </Employee>
     <Employee>
      <EmpId>EmpId_2</EmpId> 
      <Name>Name_2</Name> 
      </Employee>
      </Employees>
      </ns0:EmployeeCollection>

    Ouput :

    <ns0:Employees xmlns:ns0="http://TestingSchemas.DestinationEmployee">
    - <Employee>
      <Id>Id_0</Id> 
      <Company>Company_0</Company> 
      <EmpId>EmpId_0</EmpId> 
      <Name>Name_0</Name> 
      </Employee>
    - <Employee>
      <Id>Id_0</Id> 
      <Company>Company_0</Company> 
      <EmpId>EmpId_1</EmpId> 
      <Name>Name_1</Name> 
      </Employee>
    - <Employee>
      <Id>Id_0</Id> 
      <Company>Company_0</Company> 
      <EmpId>EmpId_2</EmpId> 
      <Name>Name_2</Name> 
      </Employee>
      </ns0:Employees>


    I hope this helps!!!!!! Please mark as Helpful.

    If this answers your question, please mark it as "Answered". It will help to reduce visits to same post as its already answered and will help guys with same question as yours without even posting it .

    Maheshkumar S. Tiwari|Team lead/Consultant(EDI/EAI)|iVision Software Pvt Ltd, Pune.


    Friday, July 5, 2013 12:04 PM
  • Do I have to write custom functiod for assigning promoted properties to elements? As I am not using any orchestration so can't do it anywhere else.

    regards


    Software Engineer

    Friday, July 5, 2013 12:18 PM
  • Hello Mahesh,

    This I am able to do. But I need all these employees as separate records not in employee collection.

    regards,


    Software Engineer

    Friday, July 5, 2013 12:20 PM
  • Hi Ram

    as Mahesh said , you can convert EmployeeCollection into Employees .

    Now you have to make Employees schema as Envelop schema

    create one receive port and two send port

    1; attach Map to recport1 , it convert Employeecollection to Employees  xml and send to sendport1.

    2: create sendport1 as recport2 , with pipeline(XMLDisassembler) and send to sendport2.

    Regards

    Mohit Gupta

    Friday, July 5, 2013 12:39 PM
  • Not sure if I understood this.

    As map is applied just before messages reaches messagebox i.e. end of pipeline. If message is debatched in pipeline then Map won't be applied and if I create map for the type which I get after debatching of the message then I will loose root level elements. If I apply only map and not debatch message then will end up with a employee collection.

    Am I able to make my self clear? Let me know If need to give some example.

    regards,


    Software Engineer

    Friday, July 5, 2013 1:23 PM
  • Hi,

    You can use the map in the ReceivePort (or in your orchestration) and you can perform a debatch within the orchestration by executing a receivepipeline, see here.

    Regards

    René

    Friday, July 5, 2013 1:30 PM
  • Thanks Rene,

    I guess this is the only option I have. Was trying to avoid this.

    regards,


    Software Engineer

    Friday, July 5, 2013 1:41 PM
  • Another way is looping through the collection yourself using xpath to select the element, like explained here, but debatching using receivepipeline gives better performance.

    Regards,

    René

    Friday, July 5, 2013 1:43 PM
  • I would suggest you change the EmployeeCollection schema to an envelope schema with the body xpath set to the Employees node, and make sure you have a schema specifically for the Employee complex type.  When you receive the EmployeeCollection message run it through a pipeline that makes use of an XML Disassembler pipeline component (whether on a receive location or in an orchestration) which will debatch the Employee nodes into seperate messages.

    Do note that debatching is a relatively expensive process, though doing it in a pipeline is the most efficient of the options if you want the debatching to happen entirely in BizTalk.

    
    • Proposed as answer by Johann Cooper Wednesday, July 10, 2013 3:51 AM
    Tuesday, July 9, 2013 5:07 AM