Free cookie consent management tool by TermsFeed Set up B2B Messaging on AS2 Gateway: The Complete Guide | Aayu Technologies Cookies preferences
Home Blog Set up B2B Messaging on AS2 Gateway: The Complete Guide

Set up B2B Messaging on AS2 Gateway: The Complete Guide

When you complete this guide, you will have a fully-functional, secure B2B document exchange pipeline over the AS2 protocol

Janaka Bandara
Janaka Bandara

This is the process that you would usually follow in AS2 Gateway (or any other AS2/EDI/MFT application) to exchange messages with your trading partners.

The same steps are explained in detail in our Quick Start Guide.

Set up AS2 Exchange/Connectivity

  1. You register as an organization (tenant) in AS2 Gateway. This gives you an admin user account, and the ability to add more users with different access levels (to work with messages, configurations, certificates, etc.) in future if required.
  2. You create a trading identity (station) representing your own organization, within AS2 Gateway.
  3. You share the public portion (partner configuration) of this trading identity/station, with your trading (business) partner - so that they can add you as a known, trusted entity in their own AS2 system.
  4. Meanwhile, you request your trading partner to send their own configuration to you. After receiving it, you use the details (ID, endpoint URL, certificates etc.) to configure a trading partner on AS2 Gateway - similar to how they would have configured your identity on their side.
  5. You send a test message from your station to your partner and ensure that you get back a successful receipt (MDN).
  6. You ask your partner to send a test message to your station, and ensure that AS2 Gateway interprets it correctly and sends back a successful MDN.
  • Depending on whether you only need to either send messages or receive messages, only one of the last 2 steps may be required.
  • If you encounter issues during any of the above steps, refer to the troubleshooting guides or contact AS2 Gateway Team for free support.

Automate/Integrate AS2 Exchange with your Existing Systems or Order Processing Pipeline

If you have a low volume of files to send or receive, the above steps may be sufficient; as long as you are happy with submitting and downloading messages by hand, through the web console.

However as and when your volume grows, you may need an easier and more reliable integration of the overall process with your existing business systems. In such cases you can use one of the integration mechanisms to plug AS2 Gateway directly into your business automation pipeline.

  • Use SFTP integration to automate the sending (upload), checking and and receiving (download) of files via standard secure file transfer protocol (SFTP) commands.
  • Use AWS S3 integration to automate file submission/retrieval - similar to SFTP, but instead, using an AWS S3 bucket as the interface.
  • Use the V1 REST API to automate the sending, checking and and receiving of files via secure HTTP/S REST API calls.
  • Use webhooks to receive real-time notifications on incoming messages and response receipts (MDNs) for outgoing ones, received by your trading stations. This avoids the need for you to keep on polling the SFTP or REST API interfaces continuously for new data, and to initiate a new workflow reactively when AS2 Gateway has actually received new data (e.g. download the received files via the SFTP/API and continue processing it on your side).

AS2 Gateway may introduce additional integration types in future, such as ability to submit/receive messages through a Google Cloud Storage bucket or Azure Blob storage - similar to how it is currently supported for AWS S3 buckets.

Configure Monitoring and Alerting

Once AS2 submission and retrieval is automated, you would need to ensure that any failures in the overall flow get notified to you, promptly and reliably:

Tracking submission rejections

With the web interface or REST API, message/file submissions are synchronous; if there is a rejection, you would receive an error message immediately as the response of the submission itself.

However with other integrations, e.g. SFTP, submissions are asynchronous; there is no reliable mechanism to inform the client that the uploaded file was not properly enqueued for delivery after the upload has been completed.

There are two main reasons for SFTP rejections:

  • The file is too large (beyond the maximum size limit; 10MB by default)
  • The uploaded path does not correspond to a valid station-partner combination; a common scenario is uploading files to the production path of a test-type partner, or vice versa

In these cases, AS2 Gateway will:

  • move the file to an error directory that is at the same level as the uploaded outbox
  • if the upload could be mapped to a valid trading station and send-failure email notifications are enabled for that station, will also send an email notification to those addresses, indicating the failure

If the file was uploaded to a completely invalid path, AS2 Gateway may not be able to perform either of these; however the chances of such an issue on an automated setup would be negligible.

Tracking AS2 send failures

Once an AS2 message is submitted for sending, AS2 Gateway will make a best-effort attempt to deliver the message. However there are scenarios that can force it to “give up” and mark the message as a permanent failure:

  • continuous network-level or processing (rare) issues that cause the message to exceed its maximum retry (resend attempt) count; 10 by default
  • partner endpoint returns a “server-error” HTTP response status (5xx range); here, similar to the previous case, AS2 Gateway will retry the transfer up to the maximum retry count
  • partner endpoint returns any other “non-OK” HTTP status (outside of the 2xx range that indicates transmission success; such as the 4xx range); in this case AS2 Gateway will not retry the transfer, because retrying could most probably result in the same error (unlike in case of a temporary network issue)

To capture above cases, you can:

After you complete these steps, you would have a fully-functional, secure B2B document exchange pipeline over the AS2 protocol - free of installation and and maintenance complexities, affordable with pay-as-you-use pricing, and ready to scale with your business needs.

Janaka Bandara

Janaka Bandara

Janaka is a Software Architect at Aayu Technologies. He is experienced in diverse areas including enterprise integration, B2B communication, and cloud and serverless technologies; and has been involved in the design and implementation of almost every Aayu product. Any interesting bug will keep him up overnight, as will tea, movies, and music.


MFT gateway
AS2 Connection as a service for B2B EDI/ file transfer
Start Free Trial View Pricing