How to handle BizTalk receive diverse sender identity from single receive location

Take EDI850 as example

LAI TOCA
3 min readFeb 10, 2023
Photo from: https://learn.microsoft.com/en-us/biztalk/core/batching-messages-for-send-processing
Photo from: https://learn.microsoft.com/en-us/azure/logic-apps/biztalk-server-to-azure-integration-services-overview

A typical BizTalk operation as above, Image that we have single receive location that accept diverse sender ID from our client but with same format (schema) of EDI type under BizTalk environment. Example as below that the file structure totally similar but merely sender identity come across different branches:

So how to handle this kind of scenario, we have already existed single location that processing the specific branch (branch-1) without any problem. If there was a good solution to tackle the different branch just configure below agreement (under “Party” of BizTalk):

EDI Agreement — (Client) -> (Our side) settings

In order to add multiple record for same type of EDI (in example is 850) under “Envelopes”. We could clone the same schema of EDI850 inside the BizTalk project, configure the “Target Namespace” and then deploy the schema to BizTalk server:

BizTalk EDI850 Project

Make sure we have unique “Target Namespace” so that we could setup separated settings inside the “Envelopes” under the “Agreement” properties.

Next, we need modify our previous BizTalk project (850 Receive) orchestration for compatible of different target namespace as we having create at the beginning (We are not prefer to clone the another duplicated orchestration or add more locations for maintainable/operation concern).

Orchestration design

(0) Defined Message under BizTalk’s orchestration (Initial step):

|Message Name|Message Type | 
|----------|:-------------:|
| MSG_Source | System.Xml.XmlDocument |
| objXML | System.Xml.XmlDocument |
| MSG_850 | X12_00401_850 (Type generated from xsd) |
| MSG_850_ORI| X12_00401_850 (Type generated from xsd) |

Define the MSG_Source as System.Xml.XmlDocument was the tricky part that we would like to receive any kind of xml format for the single receive port here.

(1) Here we change our “Receive Message” as MSG_Source to generalize receiving:

Receive Message

(2) In this step, we perform post-processing after the message was well received:

strXML = MSG_Source.OuterXml;

// replaced the source source namespace to allow same structure but different sender ID
strXML = strXML.Replace("\"http://schemas.microsoft.com/BizTalk/EDI/X12/2006/X12_00401_850_For-Branch2\"", "\"http://schemas.microsoft.com/BizTalk/EDI/X12/2006/X12_00401_850\"");

(3) Construct the target message X12_00401_850:

// load back the generalized 850 xml message
objXML = new System.Xml.XmlDocument();
objXML.LoadXml(strXML);

// only MSF_Source contains GS and ISA section's information
MSG_EDI850_ORI = MSG_Source;

// the target xml(850 formal) for next step processing (pipeline to ERP or...)
MSG_EDI850 = objXML;

MSG_EDI850.ST.ST01 = System.String.Format("{0}", System.Guid.NewGuid ());
// assign the received file name according BEG03 and Guid
MSG_EDI850(FILE.ReceivedFileName) = MSG_EDI850.BEG.BEG03 + "_" + MSG_EDI850.ST.ST01 + ".xml";

// retrieve GS02 and ISA02 information to var
strSENDER_ID = MSG_EDI850_ORI(EDI.GS02);
str_ISA_ID = MSG_EDI850_ORI(EDI.ISA08);

MSG_EDI850.ST.ST02 = System.String.Format("{0}", MSG_EDI850_ORI(EDI.ISA_Segment));
MSG_EDI850.BEG.BEG01 = System.String.Format("{0}", MSG_EDI850_ORI(EDI.GS_Segment));

The solution might not be the perfect one but it works😜.

Reference

--

--

LAI TOCA
LAI TOCA

Written by LAI TOCA

Coding for fun. (Either you are running for food or running for being food.)

No responses yet