X12 EDI Connector in Mule 4
Let's look at how to install X12 EDI Connector in Mule 4 and see real-world examples.
Join the DZone community and get the full member experience.
Join For FreeWhat Is X12?
EDI or Electronic Data Interchange permits two exchanging accomplices to trade electronic business records utilizing a typical organization. One of the generally acknowledged configurations is EDI X12. Created by the American National Standards Institute (ANSI) Accredited Standards Committee X12 (ASC X12), EDI_X12 or X12 appeared in 1979. It has since been embraced by different ventures.
There are various kinds of EDI reports. Every one compares to a "genuine world" business record, similar to receipt, value/deals inventory, human services guarantee, buy request, air shipment data, vehicle shipping request, business credit report, shipment data, and numerous others.
In the X12 EDI standard, these archives are allowed 3-digit numbers like 810 for a receipt, 832 for value/deals list, 837 for human services guarantee, 850 for buy request, etc.
You may also like:
Real-World Example
X12 EDI Connector in MuleSoft
The Connector is utilized to change over X12 messages to and from Data Weave-perfect portrayals utilizing records and maps. These are the accessible X12 variants 003010, 003020, 003030, 003040, 003050, 003060, 003070, 004010, 004020, 004030, 004040, 004050, 004060, 005010, 005020, 005030, 005040, 005050, and 006020 are bolstered with provided pattern definitions for all standard exchange sets. Numerous HIPAA record forms are likewise bolstered, as recorded independently in the Connector HIPAA reference page.
Parts of an X12 Document
An ordinary X12 record comprises of a few fragments, which are thus made out of components. Portions consistently start with a 2-3 letter code like ST or ISA. A few sections are required, while some are definitely not. The compulsory portions of X12 are:
- ISA — the trade header. This contains data about the sender and beneficiary.
- GS — the practical gathering header fragment of a lot of X12 archives of a similar record type (exchange set). Here you'll discover data about the useful gathering, for example, codes for the sender, beneficiary, and date/time of readiness.
- ST — the exchange set header portion of an X12 archive. This denotes the beginning of an exchange set in a trade.
- SE — the Transaction set trailer fragment of an X12 record. This denotes the finish of an exchange set.
- GE — the utilitarian gathering trailer portion of a lot of X12 records of a similar exchange set. It reveals to you the number of useful gatherings and the benchmark group number. It additionally denotes the finish of a gathering of exchange sets.
- IEA — this denotes the finish of the trade. It contains data about the number of utilitarian gatherings and the trade control reference number.
How to Install Edi Connector in Mule 4
Step 1:
In Anypoint Studio, click the Search tab in the palette and type the X12 EDI.
Step 2:
Click the below link i.e Try looking for it in Exchange in the studio.
Step 3:
Click and log in your any-point platform account it will redirect to exchange.
Step 4:
Select your module and install it.
Step 5:
Peruse the prompts and install the connector.
Note:
The below snapshot is described as how to install X12_edi in mule4.
Example for X12 EDI in Mule 4
Utilizing X12 EDI connector and taking JSON as a piece of information and changed over into X12 design any of the formats lists.
Please follow the below steps:
Step 1:
Create a New Mule Project Namely as X12_EDI.
Step 2:
Intuitive an HTTP listener Connector to get a solicitation for your servers and give the host and port numbers. Here, the host is set to localhost and port to 8081 and test your association with check if the port is being used or not and test it effectively.
Step 3:
Set the path as /X12Edi.
Step 4:
Drag the Transform Message Component (or Dataweave part) to change our JSON contribution to the X12 Schema group.
Example for X12 Schema
xxxxxxxxxx
form: X12
version: '004050'
imports: [ '/x12/004050/basedefs.esl' ]
id: '849'
name: 'Response to Product Transfer Account Adjustment'
class: 'CF'
heading:
- { idRef: 'ST', position: '0100', usage: M }
- { idRef: 'BRC', position: '0200', usage: M }
- { idRef: 'CUR', position: '0220', usage: O }
- { idRef: 'AAA', position: '0300', usage: O, count: 10 }
- { idRef: 'NTE', position: '0400', usage: O, count: 10 }
- { idRef: 'REF', position: '0500', usage: O, count: 12 }
- { idRef: 'PER', position: '0600', usage: O, count: 3 }
- { idRef: 'DTM', position: '0700', usage: O, count: 10 }
- groupId: 'N1_Loop'
count: 50
usage: O
items:
- { idRef: 'N1', position: '0800', usage: O }
- { idRef: 'N2', position: '0900', usage: O, count: 2 }
- { idRef: 'N3', position: '1000', usage: O, count: 2 }
- { idRef: 'N4', position: '1100', usage: O }
- { idRef: 'REF', position: '1200', usage: O, count: 12 }
- { idRef: 'PER', position: '1300', usage: O, count: 3 }
detail:
- groupId: 'CON_Loop'
count: 10000
usage: O
items:
- { idRef: 'CON', position: '0100', usage: O }
- { idRef: 'AAA', position: '0200', usage: O, count: 10 }
- { idRef: 'REF', position: '0300', usage: O, count: 12 }
- { idRef: 'PER', position: '0400', usage: O, count: 3 }
- { idRef: 'DTM', position: '0500', usage: O, count: 10 }
- groupId: 'N1_Loop'
count: 50
usage: O
items:
- { idRef: 'N1', position: '0600', usage: O }
- { idRef: 'N2', position: '0700', usage: O, count: 2 }
- { idRef: 'N3', position: '0800', usage: O, count: 2 }
- { idRef: 'N4', position: '0900', usage: O }
- { idRef: 'REF', position: '1000', usage: O, count: 12 }
- { idRef: 'PER', position: '1100', usage: O, count: 3 }
- groupId: 'PAD_Loop'
count: 1000
usage: O
items:
- { idRef: 'PAD', position: '1200', usage: O }
- { idRef: 'LIN', position: '1300', usage: O }
- { idRef: 'AAA', position: '1400', usage: O, count: 10 }
- { idRef: 'PID', position: '1500', usage: O, count: 200 }
- { idRef: 'MEA', position: '1600', usage: O, count: 40 }
- { idRef: 'UIT', position: '1700', usage: O, count: 5 }
- { idRef: 'QTY', position: '1800', usage: O, count: 5 }
- { idRef: 'AMT', position: '1900', usage: O, count: 2 }
- { idRef: 'RCD', position: '2000', usage: O }
- { idRef: 'REF', position: '2100', usage: O, count: 12 }
- { idRef: 'DTM', position: '2200', usage: O, count: 10 }
- { idRef: 'CUR', position: '2300', usage: O }
- { idRef: 'SSS', position: '2400', usage: O }
summary:
- { idRef: 'CTT', position: '0100', usage: M }
- { idRef: 'AMT', position: '0200', usage: O, count: 5 }
- { idRef: 'SE', position: '0300', usage: M }
In this record, a portion of the fields having a compulsory choice so we have to map that fields dependent on the sort.
Step 5:
Including JSON as a meta-information in DW, and guide that information into yield schema position dependent on what kind of pattern design you are selected in X12, you will comprehend that in further advances obviously.
Step 6:
Drag the X12 EDI Write connector from the mule palette After we need to allow the proper pattern in the worth segment from the different schemas in X12 container which is accessible in the project explorer.
We have to design these things, In X12 Connector
After fulfillment, we get some yield information in Dataweave, then we have to map our input JSON data to output schema data.
Step 7:
After culmination, you have to show the payload as a sort of plain/text arrangement utilizing data weave segment.
Step 8:
Run the Project
Step 9:
Open the postman and hit your service URL request as shown.
URL: http://localhost:8081/edi
Input JSON File:
xxxxxxxxxx
{
"BillingCountry": "Marguer",
"BillingCity": "Ha",
"BillingState": "Em",
"AccountNumber": "20",
"Reciever_date": "2012-04-21T18:25:43-05:00",
"Billing_Country": "gf",
"Billing_City": "na",
"Billing_State": "mau",
"Account_Number": "30",
"Name_person": "hs"
}
Step 10:
Our Output Payload as
Now, we look about the entire flow of a mule project i.e X12 EDI
Sample Code for x12 in Mule 4:
xxxxxxxxxx
<mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:x12="http://www.mulesoft.org/schema/mule/x12"
xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/x12 http://www.mulesoft.org/schema/mule/x12/current/mule-x12.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="512a9902-6b9a-4318-af40-4abaf3f568b4" >
<http:listener-connection host="0.0.0.0" port="8081" ></http:listener>
</http:listener-config>
<x12:config name="X12_EDI_Config" doc:name="X12 EDI Config" doc:id="50235ea9-3d19-43db-a8ff-d558ce971a6b" interchangeIdQualifierSelf="ZZ" initialInterchangeNumber="0" interchangeIdSelf="Mule" interchangeIdQualifierPartner="ZZ" interchangeIdPartner="DP" groupIdSelf="DA" groupIdPartner="DP">
<x12:schemas >
<x12:schema value="/x12/004050/849.esl" ></x12:schema>
</x12:schemas>
</x12:config>
<email:smtp-config name="Email_SMTP" doc:name="Email SMTP" doc:id="d4f05a42-b652-441f-b625-306e9cd3c672" >
<email:smtp-connection host="smtp.gmail.com" user="srinivasaraopotzdxvfsd@gmail.com" password="hjfbjh" port="587">
<email:properties >
<email:property key="mail.smtp.starttls.enable" value="true" ></email:property>
</email:properties>
</email:smtp-connection>
</email:smtp-config>
<flow name="edi2Flow" doc:id="06d2b429-6f23-4a0e-bcc1-6ab3b63b570c" >
<http:listener doc:name="Listener" doc:id="8fad58ba-15a4-4875-a461-597e39b5d8ac" config-ref="HTTP_Listener_config" path="/edi"></http:listener>
<ee:transform doc:name="Transform Message" doc:id="a69a7e78-ba22-4eb3-bf7f-163a4850355d" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/java
---
{
Delimiters: "*>U~",
TransactionSets: {
v004050: {
"849": [{
Interchange: {
ISA12: "dfggt"
},
Group: {
GS01: payload.BillingCountry,
GS02: payload.BillingCity,
GS03: payload.BillingState,
GS04: payload.Reciever_date as Date,
GS05: payload.AccountNumber as Number,
GS06: payload.Account_Number as Number,
GS07: payload.Billing_Country,
GS08: payload.Billing_Country
},
SetHeader: {
ST01: payload.BillingCountry,
ST02: payload.BillingCity,
ST03: payload.BillingState
},
Heading: {
"0200_BRC": {
BRC01: payload.AccountNumber,
BRC02: payload.Reciever_date as Date,
BRC03: payload.Billing_State,
BRC04: payload.Billing_City,
BRC05: payload.Account_Number as Number
}
},
Detail: {
},
Summary: {
"0100_CTT": {
CTT01: payload.AccountNumber as Number,
CTT02: payload.Account_Number as Number,
CTT03: payload.Account_Number as Number,
CTT04: payload.Name_person,
CTT05: payload.Account_Number as Number,
CTT06: payload.Billing_City,
CTT07: payload.Name_person
},
"0200_AMT": [{
AMT01: payload.Name_person,
AMT02: payload.Account_Number as Number,
AMT03: "9"
}]
}
}]
}
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="4a43fd32-e3f9-4719-a8ef-c848d1465c70" message="#[payload]" ></logger>
<x12:write doc:name="Write" doc:id="d6ce11cc-9097-435a-a8e1-c2378ce845eb" config-ref="X12_EDI_Config"></x12:write>
<logger level="INFO" doc:name="Logger" doc:id="12dd2e15-df4d-4677-aca3-c00be081a848" message="#[payload]" ></logger>
<ee:transform doc:name="Transform Message" doc:id="9d21b434-db76-4f8d-a051-5869bb334c96" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output text/plain
---
payload as String
]]></ee:set-payload>
</ee:message>
</ee:transform>
<set-payload value="#[payload]" doc:name="Set Payload" doc:id="d0ecdb65-881a-4d23-92f7-c0ce9763a5ef" mimeType="application/csv"></set>
</flow>
</mule>
Conclusion
Mule 4 accompanies bunches of upgrades and improvements. X12 Connector in Mule 3 was at that point amazing. In Mule 4, it has been rearranged for developers, and in this way, it is simple to execute and give some additional highlights.
Further Reading
Opinions expressed by DZone contributors are their own.
Comments