BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping - Orchestration


This post is part 2 of BizTalk Server : Fetching UNB and UNG Segment Values From Interchange Envelope and Mapping.


Step 5: Create Orches07ation(FetchInterchangeData)



1. Create messages


    INVOICmsg - Conforming to EDIFACT INVOIC Schema
  •  InterchangeContextmsg - Conforming to InterchangeContext Schema
  •  Invoicemsg - Conforming to CanInvoice Schema

2. Create variables


    UNBS07ing - of type S07ing
  •  xmlDoc - of type System.Xml.Document
3. Create Receive shape and configure it to accept INVOICmsg
4. Cons07uct the context message(InterchangeContext) and the Invoice message which is the final output(Invoicemsg) using Cons07uctMessage shape with following :


Message Assignment shape

Here a variable xmlDoc of type System.Xml is used and its LoadXml method is used to cons07uct the context message.

Why XmlDocument variable? The class "XmlDocument" is a super class for all XML messages, and hence it can hold any type of XML message and subsequently any type of orches07ation message.

xmlDoc.LoadXml("<ns0:Contextxmlns:ns0='http://DemoEDIFACT_FetchingSegmentValues.InterchangeContext'><UNB></UNB><UNG></UNG><ElementSeparator></ElementSeparator><SubElementSeparator></SubElementSeparator></ns0:Context>");
InterchangeContextmsg = xmlDoc;
UNBS07ing = INVOICmsg(EDI.UNB_Segment);

Assignment of EDI context values to the distinguished fields of context message

InterchangeContextmsg.UNB = INVOICmsg(EDI.UNB_Segment);
InterchangeContextmsg.UNG = INVOICmsg(EDI.UNG_Segment);

Fetching the element separator and sub element separator

InterchangeContextmsg.ElementSeparator = UNBS07ing.Subs07ing(3,1);
InterchangeContextmsg.SubElementSeparator = UNBS07ing.Subs07ing(8,1);



Here we created a intermediate message and populated it with the values coming from EDI Envelope header(which are detach during pipeline processing), so that we can use it multi-input map.


Transform Shape


Here two source are used, the incoming INVOICmsg(for the business data) and the InterchangeContextmsg(for the segment/context data) which was created in above message assignment shape




And destination as Invoicemsg

Suppose UNB1.1 segment is to be fetched then following is to be done


Configuring Scripting Functoid

1. Select Script type as External assembly
2. Select the script assembly EDIFACTSegmentValueFetcher
3. Select the script class as SegmentValueFetcher
4. Select the script method as fetchvalue



Note: Assemblies will only be available for selection if they are present in GAC.


Passing inputs to Scripting Functoid

1. Input[0] as UNB, link from InterchangeContext UNB element
2. Input[1] as ElementSeparator link from InterchangeContext ElementSeparator element
3. Input[2] as SubElementSeparator link from InterchangeContext SubelementSeparator element 
4. Input[3] as "1" hard code value
5. Input[4] as "1" hard code value




5. Create Send shape and configure it to Invoicemsg
6. Configure the logical port



7. Sign the project, build it and deploy it


Step 6: Configuring and Testing 


Download Sample




Related Posts




ServerLess360


Comments

Popular posts from this blog

The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

Getting Started with Logic Apps - AS2

How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin