Template to create inbound and outbound EDIFACT message transformation

(1 review)
Template to transform EDIFACT messages to application message format & vice versa

home

This template helps in creating translation mapping to convert:

  • Inbound EDI EDIFACT messages received from B2B trading partners to application message formats such as JSON or XML.
  • Application messages (JSON / XML) to outbound EDI EDIFACT messages to be sent to B2B trading partners.

resources/b2b-edifact-transform-template-inbound-f2489665-7a19-46c4-a675-77e37f767380.png

resources/b2b-edifact-transform-template-outbound-5ea619bb-9619-4fa1-85de-e9a195bea12c.png

Use Case

This Anypoint template serves as a foundation for creating translation maps between EDI EDIFACT message format and backend application message formats (JSON/XML), to be used in Anypoint Partner Manager or in a stand-alone Mule application.

Setup Mule project in Anypoint Studio

  • Setup Mule project in Anypoint Studio
  • Launch Anypoint Studio.
  • From the File menu, select New > Project from Template.
  • Log in to Anypoint Exchange with your Anypoint Platform credentials
  • Search for EDIFACT.
  • Click the template named Template to create inbound and outbound EDIFACT message transformation.
  • Alternatively, download the template directly from Anypoint Exchange
  • Click Open, to create a new project in your Studio workspace that is preloaded with the template
  • The project contains two Mule configuration files with pre-built template for inbound and outbound mapping
    • 01-inbound-edifact-transform.xml
    • 02-outbound-edifact-transform.xml

Create inbound EDIFACT to Application message mapping

Set the Source EDIFACT message type

  • The template (01-inbound-edifact-transform.xml) is configured with EDIFACT version D97A, ORDERS message type
  • Follow these steps to set the source EDIFACT message type for the map:
    • Click the Global Elements tab at the base of the Studio canvas in 00-global-configs.xml.
    • From Global Configuration Elements, select EDIFACT_Read and click Edit.
    • In Schema definitions, select Edit inline.
    • Select the value /edifact/d97a/ORDERS.esl and click the edit icon.

Change the schema value to the version and transaction set you want to map from.

For example, set Value to /edifact/d96a/INVOIC.esl, if you want to map from D96A Invoice message.

Set the Target JSON or XML message type

Set the target JSON or XML message type to transform inbound EDIFACT messages need to be translated to:

  1. Copy the schema file of your target application message type into the <Project-name>/src/main/resources folder in the template project.
  2. From the Mule Palette view, click the Transform Message component and drag it on to the Studio canvas.
  3. Select the Transform Message component and in the output section, next to Payload, click Define metadata.
  4. Click Add.
  5. In Type id, enter a new message type ID, for example inbound-po.
  6. Click Create type.
  7. From the Type drop-down menu in Select metadata type, select JSON or XML.
  8. Browse to the location of the JSON or XML schema file you imported in Step 1 and click Select.

resources/meta-data-type-bb07f8b3-f0aa-4fac-b8a5-58559bf9a1e2.png

EDIFACT to JSON/XML mapping

The new EDIFACT message structure displays in the input pane on the left, and your application message structure (JSON or XML) displays in the output pane on the right.

resources/edifact-inbound-map-a05d43a5-0116-47ab-b940-46b06ebaa5b2.png

You can now begin mapping from the input to the output according to your mapping specifications.

Example map for EDIFACT to JSON/XML

Download a sample project from Exchange that has pre-built mapping to transform D97A ORDERS messages into a JSON application message structure.

Create outbound application message to EDIFACT mapping

Set the Source JSON/XML message type

Set the source JSON or XML message type to define the metadata structure of your application message, such as XML or JSON:

  1. Copy the schema file of your target application message type into the <Project-name>/src/main/resources folder in the template project.
  2. Select the Transform Message component in Studio canvas of 02-outbound-edifact-transform.xml, and in the input section, next to Payload, click Define metadata.
  3. Click Add.
  4. In Type id, enter a new message type ID, for example outbound-po-ack.
  5. Click Create type.
  6. From the Type drop-down menu in Select metadata type, select JSON or XML.
  7. Browse to the location of the JSON or XML schema file you imported in Step 1 and click Select

Set the Target EDIFACT message type

  • The template (02-outbound-edifact-transform.xml) is configured with EDIFACT version D97A, ORDRSP message type
  • Follow these steps to set the source EDIFACT message type for the map:
    • Click the Global Elements tab at the base of the Studio canvas in 00-global-configs.xml.
    • From Global Configuration Elements, select EDIFACT_Write and click Edit.
    • In Schema definitions, select Edit inline.
    • Select the value /edifact/d97a/ORDRSP.esl and click the edit icon.

Change the schema value to the version and transaction set you want to map to.

For example, set Value to /edifact/d96a/INVOIC.esl, if you want to map to D96A Invoice message.

JSON/XML to EDI EDIFACT mapping

The new EDIFACT message structure displays in the output pane on the right, and your application message structure (JSON or XML) displays in the input pane on the left.

resources/edifact-outbound-map-1d71321b-108f-4e09-a6ee-8dfd99f9bf61.png

You can now begin mapping from the input to the output according to your mapping specifications.

Example map for JSON/XML to EDIFACT

Download a sample project from Exchange that has pre-built mapping to transform JSON message to D97A ORDRSP messages.

Testing the map

Follow these steps to test the translation map locally in Anypoint Studio:

  1. In Package Explorer, right-click on the template project, and select Run > Run as Mule application.
  2. Inbound:
    1. Use a REST client to post a raw EDIFACT payload to the URL http://localhost:8081/edifact/inbound.
    2. The application returns the translated application message (JSON/XML).
  3. Outbound:
    1. Use a REST client to post an input JSON/XML payload to the URL http://localhost:8081/edifact/outbound.
    2. The application returns the translated EDIFACT message.
  4. If you are using the map in Anypoint Partner Manager:After you verify that the map works correctly, copy the DataWeave map as a file with extension ".dwl".
  5. Import the dwl file to the Map section, when you create and configure inbound or outbound EDIFACT message flow in Partner Manager.

Reviews

TypeTemplate
OrganizationMuleSoft
Published by
MuleSoft Organization
Published onJun 4, 2021
Asset overview

Asset versions for 1.0.x

Asset versions
VersionActions
1.0.1
1.0.0