DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Building Scalable Real-Time Apps with AstraDB and Vaadin
Register Now

Trending

  • SRE vs. DevOps
  • Managing Data Residency, the Demo
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • What Is mTLS? How To Implement It With Istio

Trending

  • SRE vs. DevOps
  • Managing Data Residency, the Demo
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • What Is mTLS? How To Implement It With Istio

X12 EDI Connector in Mule 4

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

srinivasarao potnuru user avatar by
srinivasarao potnuru
·
Dec. 19, 19 · Tutorial
Like (3)
Save
Tweet
Share
23.05K Views

Join the DZone community and get the full member experience.

Join For Free

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
xxxxxxxxxx
1
66
 
1
form: X12
2
version: '004050'
3
imports: [ '/x12/004050/basedefs.esl' ]
4
id: '849'
5
name: 'Response to Product Transfer Account Adjustment'
6
class: 'CF'
7
heading: 
8
- { idRef: 'ST', position: '0100', usage: M }
9
- { idRef: 'BRC', position: '0200', usage: M }
10
- { idRef: 'CUR', position: '0220', usage: O }
11
- { idRef: 'AAA', position: '0300', usage: O, count: 10 }
12
- { idRef: 'NTE', position: '0400', usage: O, count: 10 }
13
- { idRef: 'REF', position: '0500', usage: O, count: 12 }
14
- { idRef: 'PER', position: '0600', usage: O, count: 3 }
15
- { idRef: 'DTM', position: '0700', usage: O, count: 10 }
16
- groupId: 'N1_Loop'
17
  count: 50
18
  usage: O
19
  items: 
20
  - { idRef: 'N1', position: '0800', usage: O }
21
  - { idRef: 'N2', position: '0900', usage: O, count: 2 }
22
  - { idRef: 'N3', position: '1000', usage: O, count: 2 }
23
  - { idRef: 'N4', position: '1100', usage: O }
24
  - { idRef: 'REF', position: '1200', usage: O, count: 12 }
25
  - { idRef: 'PER', position: '1300', usage: O, count: 3 }
26
detail: 
27
- groupId: 'CON_Loop'
28
  count: 10000
29
  usage: O
30
  items: 
31
  - { idRef: 'CON', position: '0100', usage: O }
32
  - { idRef: 'AAA', position: '0200', usage: O, count: 10 }
33
  - { idRef: 'REF', position: '0300', usage: O, count: 12 }
34
  - { idRef: 'PER', position: '0400', usage: O, count: 3 }
35
  - { idRef: 'DTM', position: '0500', usage: O, count: 10 }
36
  - groupId: 'N1_Loop'
37
    count: 50
38
    usage: O
39
    items: 
40
    - { idRef: 'N1', position: '0600', usage: O }
41
    - { idRef: 'N2', position: '0700', usage: O, count: 2 }
42
    - { idRef: 'N3', position: '0800', usage: O, count: 2 }
43
    - { idRef: 'N4', position: '0900', usage: O }
44
    - { idRef: 'REF', position: '1000', usage: O, count: 12 }
45
    - { idRef: 'PER', position: '1100', usage: O, count: 3 }
46
  - groupId: 'PAD_Loop'
47
    count: 1000
48
    usage: O
49
    items: 
50
    - { idRef: 'PAD', position: '1200', usage: O }
51
    - { idRef: 'LIN', position: '1300', usage: O }
52
    - { idRef: 'AAA', position: '1400', usage: O, count: 10 }
53
    - { idRef: 'PID', position: '1500', usage: O, count: 200 }
54
    - { idRef: 'MEA', position: '1600', usage: O, count: 40 }
55
    - { idRef: 'UIT', position: '1700', usage: O, count: 5 }
56
    - { idRef: 'QTY', position: '1800', usage: O, count: 5 }
57
    - { idRef: 'AMT', position: '1900', usage: O, count: 2 }
58
    - { idRef: 'RCD', position: '2000', usage: O }
59
    - { idRef: 'REF', position: '2100', usage: O, count: 12 }
60
    - { idRef: 'DTM', position: '2200', usage: O, count: 10 }
61
    - { idRef: 'CUR', position: '2300', usage: O }
62
    - { idRef: 'SSS', position: '2400', usage: O }
63
summary: 
64
- { idRef: 'CTT', position: '0100', usage: M }
65
- { idRef: 'AMT', position: '0200', usage: O, count: 5 }
66
- { 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:

JSON
xxxxxxxxxx
1
12
 
1
{
2
    "BillingCountry": "Marguer",
3
    "BillingCity": "Ha",
4
    "BillingState": "Em",
5
    "AccountNumber": "20",
6
    "Reciever_date": "2012-04-21T18:25:43-05:00",
7
    "Billing_Country": "gf",
8
    "Billing_City": "na",
9
    "Billing_State": "mau",
10
    "Account_Number": "30",
11
    "Name_person": "hs"
12
}


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



EDI (software) Connector (mathematics)

Opinions expressed by DZone contributors are their own.

Trending

  • SRE vs. DevOps
  • Managing Data Residency, the Demo
  • 13 Impressive Ways To Improve the Developer’s Experience by Using AI
  • What Is mTLS? How To Implement It With Istio

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: