Nav

AS2 and EDI X12 Purchase Order WalkThrough

This page shows how to use Anypoint Partner Manager to manage and track B2B processes. The goal is to develop a Mule application, representing a customer, that transforms an XML purchase order read from the filesystem to an X12 850 and sends it to a supplier over AS2. The supplier returns an X12 997 to an AS2 endpoint on which the application is listening in order to inform the customer whether the 850 was accepted or rejected. Anypoint Partner Manager manages and records all B2B exchanges while the actual files exchanged are stored on an Amazon S3 bucket.

B2B_AS2EDI_01

Audience

This document is intended for a technical audience with basic knowledge of DataMapper, AS2 Connector, X12 Module, and Anypoint Platform.

Prerequisites

  • Anypoint Studio with Mule Server 3.7.x EE runtime

  • AS2 Connector 2.x, Partner Manager Connector 2.x, and X12 Module 1.x installed

  • Anypoint Platform account

  • Amazon S3 bucket for AS2 and EDI file storage (optional)

Partnership Set Up

The first stage of the solution is to create a partnership in Anypoint Partner Manager between your organization and the supplier.

A partnership:

  • Identifies your company

  • Identifies your partner

  • Establishes the parameters by which B2B data is exchanged between you and your partner

  • Allows this data to be tracked and viewed from Anypoint Partner Manager

Set Up Home Organization Identifiers

  1. Login into Anypoint Partner Manager.

  2. On the left menu, click Trading Partners.

  3. Click on the top partner in the list, "Your company".

  4. On the left menu, click Identifiers.

  5. Enter MOUNTAINOUT as AS2 Identity and press Save.

  6. On the left menu, click X12 under FORMAT DEFAULTS.

  7. Enter MOUNTAINOUT as Interchange ID (ISA), Select ZZ (Mutually Defined) from the Interchange ID qualifier (ISA) and click Save.

Create Partner

  1. On the left menu, click Trading Partners.

  2. In the upper right corner, click New Partner .

  3. Enter My Supplier as Company Name and click Save.

Set Partner Identities and Endpoints

In this section, you will:

  • Configure the partner’s AS2 and X12 identities

  • Set the runtime parameters with which the AS2 Connector and X12 Module operate when sending to the supplier or receiving from that supplier

Create AS2 Identity

  1. On the left menu, click Identifiers.

  2. Enter My Supplier as AS2 Identity and click Save.

Configure AS2 Endpoint

  1. On the left menu, click Endpoints under CONFIGURATION.

  2. In the top right, Click New.

  3. In the Endpoint section, fill in the fields as shown in the table below:

    Field

    Value

    Name

    AS2 Send

    Protocol

    AS2

    Type

    Send

    Default

    TRUE

  4. Make sure Default for My Supplier is checked.

  5. In the Settings section, fill in the fields as shown in the table below:

    Field

    Value

    URL

    http://localhost:8082

    MDN Required

    TRUE

  6. Press Save.

  7. In the top right, Click New.

  8. In the Endpoint section, fill in the fields as shown in the table below:

    Field

    Value

    Name

    AS2 Receive

    Protocol

    AS2

    Type

    Receive

    Default

    TRUE

  9. Verify that Default for My Supplier is selected.

  10. In the Settings section, fill in the fields as shown in the table below:

    Field

    Value

    URL

    http://localhost:8081

    Default

    TRUE

  11. Click Save, then click Endpoints with the back arrow on the left menu.

Configure X12 Endpoint

  1. On the left menu, click X12 under FORMAT DEFAULTS.

  2. Enter My Supplier as Interchange ID (ISA), Select ZZ (Mutually Defined) from the Interchange ID qualifier (ISA).

  3. In the Inbound section, fill in the fields as shown in the table below: 

    Field

    Value

    Interchange sender ID qualifier  (ISA 05)

    ZZ

    Interchange sender ID (ISA 06)

    MY-SUPPLIER

    Require unique GS control numbers (GS 06)

    FALSE

  4. In the Outbound section, fill in the fields as shown in the table below:

    Field

    Value

    Interchange receiver ID qualifier (ISA 07)

    ZZ

    Interchange receiver ID (ISA 08)

    MY-SUPPLIER

    Repetition separator character (ISA 11)

    U

    Default Interchange usage indicator (ISA 15)

    Test

    Component element separator character (ISA 16)

    >

    Segment terminator character

    ~

    Data Element Delimiter

    *

    Character set

    Extended

    Character encoding

    ASCII

    Line ending between segments

    LFCR

    Require unique GS control numbers (GS 06)

    TRUE

  5. Press Save.

Mule Project Set Up

The next stage of the solution is to develop a Mule application that transforms an XML purchase order read from the filesystem to an X12 850 and sends it to the supplier over AS2. The supplier returns an X12 997 to an AS2 endpoint the application is listening on in order to inform the customer whether the 850 was accepted or rejected. The application consists of two parts:

  • A customer part that sends an 850 and receives a 997

  • A mock supplier that permits testing of the application without any external dependencies

Each part has its own Mule configuration file.

Create the Project

  1. Start Anypoint Studio.

  2. Create a new Mule project (File/New/Mule Project).

  3. Rename the initial Mule configuration file created by Studio to customer.xml .

  4. Create a new Mule configuration file (File/New/Mule Configuration File)and name it mock-supplier.

At this point, your project should as shown in this image:

B2B_AS2EDI_10

Customer Connector Configs

In this section, create the customer’s connector configs in the customer Mule config file before building the customer flows.

Creating the Partner Manager Connector Config

The Partner Manager Connector acts as a bridge between Mule and Anypoint Partner Manager. It enables the management of the AS2 Connector and the X12 module in addition to the recording of B2B exchanges.

Create Partner Manager Connector Config

  1. In Anypoint Studio, in the bottom left of the top-middle pane, click Global Elements.

    The Global Mule Configuration Elements pane appears.

  2. At the right top of the Global Mule Configuration Elements pane, click Create.

    The Choose Global Type dialog box appears. Click Connector Configuration.

    A selection list appears.

  3. From the selection list, if you have access to an Amazon S3 bucket, select Partner Manager: Amazon S3 File Storage. This configuration type allows the Partner Manager Connector to persist X12 documents and AS2 message content to Amazon S3.

    Otherwise, select Partner Manager: Basic Configuration.

    Click OK. The Global Element Properties page appears.

Completing the Global Element Properties Page

The Global Element Properties Page requires you to enter an API Key and an Environment ID.

If you have an existing API Key, use it. If you do not know it, consult your organization’s MuleSoft representative.

If your organization has not created an API Key, you can create one.

The API Key is used by any Mule application across your entire Master Organization that communicates with Anypoint Partner Manager. Therefore, before you create a new API Key, coordinate with your organization’s MuleSoft administrator to ensure that none of your organization’s processes are using an existing API Key because, if they are, creating a new API Key will cause them to cease functioning. In that case, instead of creating a new API Key, use the existing API Key.

To obtain a key, see Create a New API Key.

You can determine your environment ID on the same page that you create a new API key.

Complete the Global Elements Properties Page

  1. In the API Key box, enter your API key.

  2. In the Environment ID box, enter your Environment ID.

  3. Click OK.

Create HTTP Global Endpoints

In this step, you add the HTTP global endpoints required by the AS2 Connector to shuttle messages across the wire.

  1. Inside Global Elements, go to Create > Connector Endpoints > HTTP. Name the endpoint receive-http-endpoint and ensure that it has configured an HTTP connector.

  2. Repeat the previous step, however, set the endpoint name for this step to send-http-endpoint.

  3. Set the Port attribute for receive-http-endpoint  to 8081 while for send-http-endpoint enter the placeholder ${as2.http.port}. We use a placeholder for the destination port since it’s injected at runtime by Anypoint’s B2B service.

  4. Set the Host attribute for send-http-endpoint to the placeholder ${as2.http.host}. The destination hostname is also injected at runtime.

Create AS2 Connector Configs

  1. Remain in the Global Elements view to create two AS2 Connector configurations by going to Create > Connector Configuration > AS2: Partner Manager Configuration. Name them send-as2-config and receive-as2-config.

  2. Select X12 from the Standard drop-down list.

  3. Bind send-as2-config and receive-as2-config to send-http-endpoint and receive-http-endpoint, respectively. See AS2 Connector 2.0.0 for further information about configuring the AS2 Connector.

Create X12 Module Config

  1. In the Global Elements view, go to Create > Connector Configuration > X12 EDI to create an X12 Module config.

  2. Enable Use B2B Provider to allow Anypoint Partner Manager to manage and track X12 exchanges.

  3. Check the Create Object Manually radio button and open the Object Builder to enter the schema path /x12/005010/850.esl in the first entry list.

    B2B_AS2EDI_14

  4. Set the interchange identifier attributes so that they correspond with the interchange identifiers you configured in Anypoint Partner Manager:

    Self identification:

    
                 
              
    1
    2
    3
    
    Interchange sender/receiver ID qualifier = _ZZ_
    Interchange sender/receiver ID = _MOUNTAINOUT_
    Application sender/receiver code = _MOUNTAINOUT_

    Partner identification:

    
                 
              
    1
    2
    3
    
    Interchange sender/receiver ID qualifier = _ZZ_
    Interchange sender/receiver ID = _MY-SUPPLIER_
    Application sender/receiver code = _MY-SUPPLIER_

    The interchange identifiers serve as the lookup key for finding the partnership to use for X12 processing.

    The following screenshot should match what you have in the Global Elements view:

    B2B_AS2EDI_15

Transform and Send 850 over AS2

With the connector configs out of the way, construct a flow to read an XML purchase order from the filesystem, transform it to a canonical EDI message structure, and finally, write it out as an X12 850 document to send it out to your supplier over AS2.

  1. Remain in the customer Mule config but change to the Message Flow view.

  2. Drag a File message source to the canvas to create a flow. Set the Path attribute to outbox.

  3. Add a DataMapper next to the File message source.

  4. Put an X12 processor after the DataMapper. Set the Connector Configuration to the X12 config that you created in the previous section and select Write for the Operation.

  5. Go back to the DataMapper. Select for input type XML and use the schema po.xsd to derive the structure to be mapped. Click the Create mapping button. You can download a copy of as2-x12-po.xsd and rename it to be po.xsd.

    B2B_AS2EDI_16

  6. Perform the mapping from XML to X12 850 as follows:

    Source: XML

    Target: X12 850

    PurchaserOrderNumber

    BEG03 - Purchase Order Number

    '00'

    BEG01 - Transaction Set Purpose Code

    'NE'

    BEG02 - Purchase Order Type Code

    OrderDate

    BEG05 - Date

    Quantity

    PO102 - Quantity

    USPrice

    PO104 - Unit Price

    PartNumber

    PO107 - Produce/Service ID

    TotalPrice

    Summary → 100_CTT → 0200_AMT → AMT02 - Monetary Amount

    'TT'

    Summary → 100_CTT → 0200_AMT → AMT01 - Amount Qualifier Code

  7. The last message processor in the flow is an AS2 processor that sends the 850. Set the  the operation to Send. Additionally, set AS2-From and AS2-To to your Home organization’s AS2 identifier and the partner’s AS2 identifier, respectively:

    
                
             
    1
    2
    
    AS2-From = _MOUNTAINOUT_
    AS2-To = _MY-SUPPLIER_

    Note that these identifiers were set in Anypoint Partner Manager. The AS2 identifiers serve as lookup keys for finding the partnership to use for transmitting the AS2 message.

    B2B_AS2EDI_17

Receive 997 over AS2

The subsequent flow to develop will receive a 997 over AS2 from the supplier in response to the 850 sent by you. In the customer.xml Mule config:

  1. Drag the AS2 processor to the canvas so as to create a message source for a new flow.

  2. Add an X12 processor next to the message source and select the Read operation. Point the Connector Configuration to the X12 Module config that you created in the previous section

    B2B_AS2EDI_18

Develop Mock Supplier

The mock supplier receives the 850 and generates a 997 to send back to the customer over AS2:

  1. Open the mock-supplier.xml Mule config.

  2. Similar to what you did for the customer, create a pair of HTTP global endpoints, a pair of AS2 Connector configs, and an X12 Module config. Ensure that:

    • Use B2B Provider remains disabled for all EDI configs.

    • Basic AS2 Connector configs are created: CreateConnector ConfigurationAS2: Configuration.

    • Each AS2 endpoint is bound to its respective HTTP global endpoint.

    • X12 Module config schema path is set to /x12/005010/850.esl.

    • Unique names are given to the configs.

      The following screenshot should match what you have in the mock supplier’s Global Elements view:

      B2B_AS2EDI_19

  3. Switch to the Message Flow view. Drag the AS2 processor to the canvas and select the Receive operation. Make sure that Connector Configuration points to the mock supplier’s AS2 config.

  4. Add an X12 processor to the flow. Select the mock supplier’s X12 config for Connector Configuration and set  its Operation to Read.

  5. After the 850 is parsed by the X12 processor, the generated 997 needs to be extracted from the payload. Add the Set Payload processor to the processor chain and enter in its Value attribute: #[ ['TransactionSets' : [ 'v005010' : [ '997' : payload.FunctionalAcksGenerated ] ] ] ].

  6. Add another X12 processor to serialize the 997. Select the mock supplier’s X12 config for Connector Configuration. Expand the Operation drop-down list and select Write.

  7. The last step in the flow to send the 997 over AS2. Append an AS2 processor to the flow and enter MY-SUPPLIER in AS2-From and MOUNTAINOUT in AS2-To.

    B2B_AS2EDI_21

Run Application

  1. Run the application as a Mule Application. On startup, the application creates the outbox directory in the project’s root directory. If the outbox directory isn’t visible, try refreshing the project in the Package Explorer view.

  2. Drop the purchase order file po.xml, included with this document, in the outbox directory. The file should disappear from the directory since the File inbound endpoint deletes the file after it reads it.

  3. Access the B2B Transmissions page in Anypoint Partner Manager to confirm that the AS2 and X12 transmissions have taken place.

    B2B_AS2EDI_22