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

How to Send AS2 Messages With an EDI Trading Platform

DZone 's Guide to

How to Send AS2 Messages With an EDI Trading Platform

When the business involves confidential data, security will be a major concern for all enterprises.

· Security Zone ·
Free Resource

message-neon-sign-white

Keep your confidential data secure

When business involves lots of confidential data, security becomes a major concern for all enterprises. Therefore, going for an EDI trading platform with a secure file transfer protocol is essential. AS2 Gateway is a SaaS EDI trading platform that is created based on AS2 protocol to provide secure communication for B2B enterprises.

In addition to all the benefits packaged with AS2 protocol, AS2 Gateway itself provides a flexible, easy-to-use, personalized piece of software to the customers. So, in this article let's talk about how to send AS2 messages via AS2 Gateway.

You may also like: Getting Started With AS2 Protocol Using AS2Gateway and OpenAS2

Creating an Account 

To get started with AS2 Gateway, you have to register your organization by giving a few details like domain name, name, administrator's name, email address, etc.

Creating an account

Creating an account

Once you have submitted the details, an account in AS2 Gateway will be created for your organization. When you log in, you will see a dashboard view where users can monitor the number of messages transferred within a particular period with graphical representations.

Dashboard view

Dashboard view

Creating a Station

To start sending messages via AS2 Gateway, you have to create a trading station for your organization, which will act as your local endpoint. To configure a station, go to the Stations UI and click the New Station button.

Adding a new station

Adding a new station

In the Station configuration UI, provide a name to your trading station, and a unique AS2 identifier to use in messaging. Then, you have to provide an email address, which can also be used to get notifications for receiving messages from the station. You can also add a small description of your station.

AS2 Gateway provides three options to configure a certificate for the station.

  1. Generate New Key Store: AS2 Gateway will create a key store on behalf of you.
  2. Upload Existing Key Store: a key store in your local machine can be uploaded.
  3. Select from Certificate Store: a certificate that already exists in your AS2 Gateway account.

Once you have submitted the form, the station will be created and will appear in the Stations UI, as shown below.

Example station

Example station

On the station block, you can see four icons, as shown below.

  1. Manage Station: Where you can view and edit station details.
  2. View Partner Configuration: Where you can find configuration details like AS2 identifier, the message receiving URLs, certificates that you should share with your trading partners. There, you can provide your partner's email address and directly share these configuration details to your partner.
  3. View Station Statistics: Where you can view statistics of messages sent and received through the station.
  4. Delete Station: When deleting a station, all the messages associated with that station will be permanently deleted.

Creating a Partner

After configuring a station, you have to add your clients as trading partners. They will act as the receiving endpoints of your station's outbound messages, and you can receive messages from them as well. To set up a partner, go to the Partners UI and click the New Partner button.

Adding a new partner

Adding a new partner

Give the name of your trading partner. Select your partner type: Test or Production. Then, provide an AS2 identifier, which will uniquely identify the trading partner you are gonna address when exchanging messages. After, you can state a small description of your partner. This will be helpful to easily identify the relevant partner if you are going to create more than one.

Then, provide the AS2 message receiver URL of the partner and the encryption certificate, which you have already received from them. If your partner has separate certificates for encryption and signing, you can provide the latter as well.

You can set a predefined message subject for your trading partner, which will be used if you haven't provided a specific subject while sending a message. Under advanced settings, you can customize AS2 message configurations like encryption, sign algorithms, and the nature of the expected MDN (receipt), specific to the trading partner.

Send AS2 Messages

Once you have successfully configured a station and a partner, you are ready to send messages via an AS2 Gateway. You can go to the Messages UI by the sidebar menu or just click the Send New Message icon on the bottom right corner on any page. Then, in the New message view, select the relevant station and partner from the dropdown list, specify a message subject (optional), attach a document(s), and click the Send button.

Sending a new message

Sending a new message

The message will be added to the queue, and you will be redirected to the "Queued Messages" view, which displays the status of the outbound message. If the message was successfully delivered to the partner, the message will be moved to the Sent view where you can find all the necessary details of the message.

After 10 automatic retries, if AS2 Gateway is unable to successfully send the queued message out, it will be moved to the Failed view where you can find its failure reason, along with other message details.

Send AS2 Messages via SFTP

When sending/receiving a large number of documents, it's better to use an integration mechanism like SFTP. Also, if you prefer to integrate internal systems with your trading platform, it's a perfect choice for you to go with AS2 Gateway SFTP connectivity, which you can configure to automate inbound message flow.

To set up SFTP with AS2 Gateway, go to the SFTP tab from the sidebar menu.

SFTP tab

SFTP tab

Give a valid username and password and click the Setup SFTP button.

Once the configurations are done, download the private key by clicking on the Export Key button. The downloaded file name will be something like id_rsa_username. Navigate to the directory where it is downloaded through the terminal and execute below command (for Linux and macOS), replacing {private_key_file} with your private key file name to set correct permissions to the file.

chmod 400 {private_key_file}

Then, to log in to the AS2 Gateway SFTP server, run the following command, replacing {private_key_file} and {sftp_username} with your own.

sftp -P 9193 -i {private_key_file} {sftp_username}@sftp.as2gateway.com

Once you have run the command, it will ask to enter a passphrase, which is the password you have given when setting up SFTP. After that, you can successfully connect to the AS2 Gateway's SFTP server. There, you can see a directory named as2gateway and private and public keys of your SFTP user.

In the as2gateway directory, you will find directories created for each station that associated with your organization. Each of these directory labels is created under the unique AS2 identifier assigned to the respective station. In each station directory, you will find directories being created for each partner AS2 identifier associated with your organization.

To send documents from AS2 Gateway, transfer your documents via SFTP to the following SFTP path.

If partner type is Production: as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/outbox

If partner type is Test: as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/outbox

When sending a multi-document message via SFTP you have to create a folder inside the outbox [ as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/outbox/ or as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/outbox/ ] directory and upload your documents to the newly created folder. Two minutes after the last file is uploaded, AS2 Gateway will pick up and send all files as one message to the relevant trading partner.

You can download the receiving files via SFTP through the following SFTP path.

If partner type is Production: as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/inbox

If partner type is Test: as2gateway/(AS2-Station-ID)/(AS2-Partner-ID)/test/inbox

In the inbox directory, all incoming messages will be either separated into subdirectories based on the received timestamp or saved directly in inbox directory with timestamp prefixes — according to user preference.


Further Reading

Topics:
as2 ,as2 message ,as2 trading ,b2b ,b2b integration ,sftp ,security

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}