{{announcement.body}}
{{announcement.title}}

X12 EDI Connector in Mule 4

DZone 's Guide to

X12 EDI Connector in Mule 4

Let's look at how to install X12 EDI Connector in Mule 4 and see real-world examples.

· Integration Zone ·
Free Resource

Red X spray painted on white wall

What 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:

  1. ISA — the trade header. This contains data about the sender and beneficiary.
  2. 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.
  3. ST — the exchange set header portion of an X12 archive. This denotes the beginning of an exchange set in a trade.
  4. SE — the Transaction set trailer fragment of an X12 record. This denotes the finish of an exchange set.
  5. 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.
  6. 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

Plain Text


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:

JSON


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:

XML
xxxxxxxxxx
1
103
 
1
<?xml version="1.0" encoding="UTF-8"?>
2
 
          
3
<mule xmlns:email="http://www.mulesoft.org/schema/mule/email" xmlns:file="http://www.mulesoft.org/schema/mule/file"
4
    xmlns:x12="http://www.mulesoft.org/schema/mule/x12"
5
    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
6
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
7
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
8
http://www.mulesoft.org/schema/mule/x12 http://www.mulesoft.org/schema/mule/x12/current/mule-x12.xsd
9
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
10
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
11
    <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="512a9902-6b9a-4318-af40-4abaf3f568b4" >
12
        <http:listener-connection host="0.0.0.0" port="8081" ></http:listener>
13
    </http:listener-config>
14
    <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">
15
        <x12:schemas >
16
            <x12:schema value="/x12/004050/849.esl" ></x12:schema>
17
        </x12:schemas>
18
    </x12:config>
19
    <email:smtp-config name="Email_SMTP" doc:name="Email SMTP" doc:id="d4f05a42-b652-441f-b625-306e9cd3c672" >
20
        <email:smtp-connection host="smtp.gmail.com" user="srinivasaraopotzdxvfsd@gmail.com" password="hjfbjh" port="587">
21
            <email:properties >
22
                <email:property key="mail.smtp.starttls.enable" value="true" ></email:property>
23
            </email:properties>
24
        </email:smtp-connection>
25
    </email:smtp-config>
26
    <flow name="edi2Flow" doc:id="06d2b429-6f23-4a0e-bcc1-6ab3b63b570c" >
27
        <http:listener doc:name="Listener" doc:id="8fad58ba-15a4-4875-a461-597e39b5d8ac" config-ref="HTTP_Listener_config" path="/edi"></http:listener>
28
        <ee:transform doc:name="Transform Message" doc:id="a69a7e78-ba22-4eb3-bf7f-163a4850355d" >
29
            <ee:message >
30
                <ee:set-payload ><![CDATA[%dw 2.0
31
output application/java
32
---
33
{
34
    Delimiters: "*>U~",
35
    TransactionSets: {
36
        v004050: {
37
            "849": [{
38
                Interchange: {
39
                    ISA12: "dfggt"
40
                },
41
                Group: {
42
                    GS01: payload.BillingCountry,
43
                    GS02: payload.BillingCity,
44
                    GS03: payload.BillingState,
45
                    GS04: payload.Reciever_date as Date,
46
                    GS05: payload.AccountNumber as Number,
47
                    GS06: payload.Account_Number as Number,
48
                    GS07: payload.Billing_Country,
49
                    GS08: payload.Billing_Country
50
                },
51
                SetHeader: {
52
                    ST01: payload.BillingCountry,
53
                    ST02: payload.BillingCity,
54
                    ST03: payload.BillingState
55
                },
56
                Heading: {
57
                    "0200_BRC": {
58
                        BRC01: payload.AccountNumber,
59
                        BRC02: payload.Reciever_date as Date,
60
                        BRC03: payload.Billing_State,
61
                        BRC04: payload.Billing_City,
62
                        BRC05: payload.Account_Number as Number
63
                    }
64
                },
65
                Detail: {
66
                },
67
                Summary: {
68
                    "0100_CTT": {
69
                        CTT01: payload.AccountNumber as Number,
70
                        CTT02: payload.Account_Number as Number,
71
                        CTT03: payload.Account_Number as Number,
72
                        CTT04: payload.Name_person,
73
                        CTT05: payload.Account_Number as Number,
74
                        CTT06: payload.Billing_City,
75
                        CTT07: payload.Name_person
76
                    },
77
                    "0200_AMT": [{
78
                        AMT01: payload.Name_person,
79
                        AMT02: payload.Account_Number as Number,
80
                        AMT03: "9"
81
                    }]
82
                }
83
            }]
84
        }
85
    }
86
}]]></ee:set-payload>
87
            </ee:message>
88
        </ee:transform>
89
        <logger level="INFO" doc:name="Logger" doc:id="4a43fd32-e3f9-4719-a8ef-c848d1465c70" message="#[payload]" ></logger>
90
        <x12:write doc:name="Write" doc:id="d6ce11cc-9097-435a-a8e1-c2378ce845eb" config-ref="X12_EDI_Config"></x12:write>
91
        <logger level="INFO" doc:name="Logger" doc:id="12dd2e15-df4d-4677-aca3-c00be081a848" message="#[payload]" ></logger>
92
        <ee:transform doc:name="Transform Message" doc:id="9d21b434-db76-4f8d-a051-5869bb334c96" >
93
            <ee:message >
94
                <ee:set-payload ><![CDATA[%dw 2.0
95
output text/plain
96
---
97
payload as String
98
]]></ee:set-payload>
99
            </ee:message>
100
        </ee:transform>
101
        <set-payload value="#[payload]" doc:name="Set Payload" doc:id="d0ecdb65-881a-4d23-92f7-c0ce9763a5ef" mimeType="application/csv"></set>
102
    </flow>
103
</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



Topics:
mule 4 ,integration ,tutorial ,x12 edi connector ,electronic data interchange

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}