Debatching(Splitting) XML Message in Orchestration using DefaultPipeline - BizTalk 2010

 
In this post we will walk through the process of debatching an xml message in Orchestration using pipeline in Biztalk.

I have used the Default XML Receive pipeline to achieve it, but it can also be done by creating a custom pipeline which uses XML disassembler (where you can set the Envelope and Document Schema).

Pipeline is not available in Orchestration like other shapes, thus to use it we need to add reference to following assemblies(which will allow us to use methods in those assemblies) :

  • Microsoft.XLANGs.Pipeline.dll
  • Microsoft.BizTalk.Pipeline.dll

You can browse to the location BizTalk Installation Directory to find above dll's.

Most of the part of this post is borrowed from my earlier post which talks about debatching xml at receive port:
http://tech-findings.blogspot.in/2013/07/debatchingsplitting-xml-message-biztalk.html

Scenario:

We receive many item information but its wrapped (Enveloped) , so to process each item we need to unwrap it (remove the envelope and split individual Item message).

Below is what we receive (Input) :
<ns0:Items xmlns:ns0="http://TestingSchemas.ItemEnvelope">
  <ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_0</ID> 
  <Name>Name_0</Name> 
  <Quantity>100</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
  <ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_0</ID> 
  <Name>Name_1</Name> 
  <Quantity>200</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
  <ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_2</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_3</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_4</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_5</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_6</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_7</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_8</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
<ns1:Product xmlns:ns1="http://TestingSchemas.Item">
  <ID>ID_9</ID> 
  <Name>Name_2</Name> 
  <Quantity>300</Quantity> 
  <UnitPrice>100</UnitPrice> 
  </ns1:Product>
  </ns0:Items>

But we want (Output) :

      <ns0:Product xmlns:ns0="http://TestingSchemas.Item">
           <ID>ID_0</ID>
          <Name>Name_0</Name>
          <Quantity>100</Quantity>
          <UnitPrice>100</UnitPrice>
      </ns0:Product>
             .
             .
             .
             .
             .
 
     <ns0:Product xmlns:ns0="http://TestingSchemas.Item">
        <ID>ID_9</ID>
        <Name>Name_9</Name>
        <Quantity>100</Quantity>
        <UnitPrice>100</UnitPrice>
     </ns0:Product>
 
 
All right, let's see how we do it:
 
1. Create schema - document schema 
 
2. Create the wrapper - Envelope Schema
 
  • Name the root node, I have named it Items.
 
 
 
  • Click on "Schema" and go to Properties Window
  • Set the property "Envelope" as Yes, as this schema will be used as envelope and this is the property which helps disassembler to recognize it.
  • So far good, envelope schema is ready but what about the document which will be wrapped.
  • In the Property window select "Imports" and click on the ellipsis
  • You will get Imports wizard pop-ed  out  .
  • Click on add and select the document schema which we created in step 1.(Here it is Item schema)
 
 
 
  • Click on the "Items" and go to property window and select the property Body XPath and set it to /*[local-name()='Items' and namespace-uri()='http://TestingSchemas.ItemEnvelope']. Doing so allows an Items node to contain any number of Item Document.
  • Cool... Now we are ready with the resources, next is to validate schema, build it, sign it  and deploy.
 
 
 
 
3. Now lets create Orchestration which will receive the enveloped item and debatch/split it using the pipeline.

 
  • Receive shape is configured to receive untyped message i.e. of type System.Xml.XmlDocument (which will receive enveloped message -ItemEnvelope Type) .
  • Then we have a "DebatchScope"  which is of type "Atomic" and Orchestration  is of type Long running. Why Atomic scope? Because we will be calling/executing Pipeline within it and the pipeline is of non- serializable type.
  • Next we have Expression shape named as "Execute Pipeline". It is here where we make call to pipeline  and execute it which results in splitted messages.
  • It contains following line:  GetPipelineOutput=Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(Microsoft.BizTalk.DefaultPipelines.XMLReceive),ItemsIn);
  • GetPipelineOutput is a DebatchScope variable of type: Microsoft.XLANGS.Pipeline.ReceivePipelineOutputMessages
  • So we are executing the method ExecuteReceivePipeline()  method of XLANGPipelineManager class  which belongs to Microsoft.XLANGs.Pipeline and its output assigned to  GetPipelineOutput.
 

 
  • Then we have a loop shape "UntilLastMessage" and its same as  while loop, below is the condition(tillspillited messages are available) : GetPipelineOutput.MoveNext()
  • Next is Construct shape with Message Assignment within it, which has following code:
 ItemOut = null;
          GetPipelineOutput.GetCurrent(ItemOut);
 
It is here where the splitted single  message is assigned to ItemOut , where ItemOut is a Message variable which is of type Item.xsd
  • At last we have Send shape which accepts message of type ItemOut and sends it .
  • Now what, build the project , sign it and deploy .
4.Now create a Receive and Send port :

  • Receive Pipeline is PassThruReceive  as we don't want its message type to be detected until the message reaches to ExecutePipeline shape in Orchestration.

  • Now after both the ports are ready, it's time to bind it to the logical ports of our orchestration:
 
5. Start the application and test it, I will drop a envelope message at receive location which we saw at start  . So I should be getting 10 individual xml message at the destination location:

 
 
 
 
 
        Will keep on posting as an when I find something to share!!!!!!!!!!!!

Debatching(Splitting) XML Message in Orchestration using DefaultPipeline - BizTalk 2010的更多相关文章

  1. Unable to perform unmarshalling at line number 16 and column 63 in RESOURCE hibernate.cfg.xml. Message: cvc-elt.1: 找不到元素 'hibernate-configuration' 的声明。

    七月 02, 2017 4:32:37 下午 org.hibernate.Version logVersionINFO: HHH000412: Hibernate Core {5.2.10.Final ...

  2. BizTalk开发小技巧

    BizTalk开发小技巧 随笔分类 - Biztalk Biztalk 使用BizTalk实现RosettaNet B2B So Easy 摘要: 使用BizTalk实现RosettaNet B2B ...

  3. [Java Basics3] XML, Unit testing

    What's the difference between DOM and SAX? DOM creates tree-like representation of the XML document ...

  4. PHP 开发 APP 接口 学习笔记与总结 - XML 方式封装通信接口

    1.PHP 生成 XML 数据 ① 拼接字符串 ② 使用系统类(DomDocument,XMLWriter,SimpleXML) 例1 使用 PHP 系统类中的 DomDocument 类: < ...

  5. XMl的解析简单的方法

    首先需要jia包 xstream-1.4.7.jar Vo类 package com.zld.day06_03zk3demo.bean; import java.io.Serializable; im ...

  6. xml解析(4)

    本节要点: DOM解析方式 SAX解析方式 DOM4J对XML的解析 XML用于将数据组织起来,形成文档用于存储和传输: 更多时候我们需要的是将xml中的数据解析出来,甚至是在程序中动态生成xml. ...

  7. php生成xml数据

    1.php生成xml数据一般有2种方式, 一个是组装字符串,另一个就是使用php内置的系统类 2.使用php内置类生成xml数据 3.拼装字符串生成xml数据 public function stat ...

  8. Play XML Entities

    链接:https://pentesterlab.com/exercises/play_xxe/course Introduction This course details the exploitat ...

  9. Modifying namespace in XML document programmatically

    Modifying namespace in XML document programmatically static XElement stripNS(XElement root) { return ...

随机推荐

  1. 1.4eigen中的块运算

    1.4 块运算 块是矩阵或数组的一个矩形部分.块表达式既可以做左值也可以作右值.和矩阵表达式一样,块分解具有零运行时间成本,对你的程序进行优化. 1.使用块运算 最常用的块运算是.block()成员函 ...

  2. java29

    1.封装小练习--长方形 创建长方形类 使用getset方法 利用返回值方法计算长方形的面积,周长. 保证长方形的长宽为整数 2.继承小练习--猫狗 当父类中有构造器时,子类也要有构造器,并且要求设置 ...

  3. 移动端web轮播图插件swiper,功能很强大

    使用方法示例: <div class="swiper-container"> <div class="swiper-wrapper"> ...

  4. MVC Log4Net 配置

    1.引用log4net.dll 2.在项目根目录下增加log4.config文件 <?xml version="1.0"?> <configuration> ...

  5. 3 week work—Grid Layout

    HTML: <div class="wrapper"> //建立一个三列轨道网格. <div class="one">One</d ...

  6. 关于ASP.NET MVC 中JsonResult返回的日期值问题

    最近开始用MVC做项目,在使用 JsonResult返回数据的时候,日期被反射成了/Date 1233455这种格式,遍查网上都是在客户端使用JS来处理这个问题的,这样的话,就需要在每一个涉及到日期的 ...

  7. 简单的异步函数async/await例子

    function resolveAfter2Seconds(x){ return new Promise(resolve => { setTimeout(() => { resolve(x ...

  8. Eclipse 中 SVN 插件的安装与使用

    下载和安装SVN插件 插件在线安装 可以选择在线安装插件的方式,就是使用eclipse里Help菜单的“Install New Software”,通过输入SVN地址,直接下载安装到eclipse里. ...

  9. JavaScript中关于页面URL地址的获取

    1 window.location.host; //返回url的主机部分,例如 www.xxx.com window.location.hostname; //返回url的主机名,例如 www.xxx ...

  10. Shell-3--变量

    用户自定义变量 环境变量 位置参数变量 预定义变量