MuleSoft Connectors: Asynchronous Responses with AS2 Receive

Requirements: /n software Connectors for MuleSoft


The /n software Connectors for MuleSoft extend the functionality of MuleSoft and provide robust enterprise-ready Internet connectivity, secure messaging, and file transfer.

Our AS2 Receive connector supports generating synchronous and asynchronous receipts. Please see the Getting Started article for more information on getting up and running with an AS2 Receive connector and HTTP Listener.

Asynchronous Receipts

The incoming AS2 message will specify whether a receipt should be returned synchronously or asynchronously. A request for a receipt is defined by the presence of the Disposition-Notification-To and Disposition-Notification-Options headers. A request for an asynchronous receipt is defined by the presence of a Receipt-delivery-option header. For example:

Disposition-Notification-To: SomeData Disposition-Notification-Options: signed-receipt-protocol=optional, pkcs7-signature; signed-receipt-micalg=optional, sha-256 Receipt-delivery-option:

When replying to the original AS2 message with an asynchronous receipt, the server should respond with a 200 OK HTTP response. At a later time, the server should POST the receipt over a separate connection to the location specified in the original message. Below are the steps for setting up AS2 Receive to acheive this.

AS2 Receive

The default behavior of the connector is to return a receipt to the sender synchronously via the HTTP Listener. Asynchronous delivery is possible with AS2 Receive by adding an intermediate directory and separate flow to send the receipt.

To configure a project to send the receipt asynchronously, please follow the below steps.

An example AS2 Receive flow

First, open the configuration page for the connector which handles the incoming AS2 message. Set the AsyncMDNInfoDir Other setting to a path on the local filesystem where the connector can write the receipt and receipt metadata.

Next, create a new flow using a desired event source (in this case, a scheduler is used for simplicity). Add a File List connector and a For Each Scope behind it, to iterate over the stored asynchronous MDN's at the location from step one.

Next, add an AS2 Receive connector inside the For Each Scope and set the ReceiveMode to AsyncMDN. This will configure the receive connector to perform the send receipt operation for asynchronous MDN's stored in this directory.

Finally, after the MDN is successfully sent it should be deleted from the intermediate directory using a File Delete connector.

Configuration XML:

<?xml version="1.0" encoding="UTF-8"?> <mule xmlns:file="" xmlns:http="" xmlns:nsoftware_AS2="" xmlns:nsoftware_AMQP="" xmlns="" xmlns:doc="" xmlns:xsi="" xsi:schemaLocation=""> <http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config"> <http:listener-connection host="" port="8089" /> </http:listener-config> <nsoftware_AS2:receiver-config name="Nsoftware_AS2_Receiver_config" doc:name="Nsoftware AS2 Receiver config" ReceivingPartner="testas2" TradingPartner="testas2" MessageSecurity="None" LogMode="Verbose"> <nsoftware_AS2:mdn-signing-cert Store="C:\Dev\branches\v20\IPWorksEDI\tests\files\100.pfx" StorePassword="test" StoreType="PFXFile" Subject="*" /> <nsoftware_AS2:signer-cert AcceptAny="true" /> <nsoftware_AS2:other > <nsoftware_AS2:other-text >AsyncMDNInfoDir=C:\temp\test</nsoftware_AS2:other-text> </nsoftware_AS2:other> </nsoftware_AS2:receiver-config> <nsoftware_AS2:receiver-config name="Nsoftware_AS2_Receiver_config1" doc:name="Nsoftware AS2 Receiver config" ReceiveMode="AsyncMDN" ReceivingPartner="*" TradingPartner="*" LogMode="Verbose"/> <flow name="AS2Endpoint" initialState="started"> <http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/testas2"/> <nsoftware_AS2:receive doc:name="Receive" config-ref="Nsoftware_AS2_Receiver_config"/> <logger level="INFO" doc:name="Logger" message="#[attributes.AS2MessageId]"/> </flow> <flow name="AsyncDelivery"> <scheduler doc:name="Scheduler"> <scheduling-strategy > <fixed-frequency frequency="5" timeUnit="SECONDS"/> </scheduling-strategy> </scheduler> <file:list doc:name="List" directoryPath="C:\temp\test"/> <foreach doc:name="For Each" rootMessageVariableName="fileMessage"> <set-variable value="#[attributes.fileName]" doc:name="Set Variable" variableName="mdnfilename"/> <nsoftware_AS2:receive doc:name="Receive" config-ref="Nsoftware_AS2_Receiver_config1"/> <logger level="INFO" doc:name="Logger" message="#[vars.mdnfilename]"/> <file:delete doc:name="Delete" path="#[vars.mdnfilename]"/> </foreach> </flow> </mule>

Additional Tips

Depending on the deployment environment it may not be desirable to write files to an intermediate directory. In this case, instead of using the built-in AsyncMDN receive mode you can send the receipt using existing Mule mechanisms. After an incoming AS2 message has been processed by AS2 Receive, the attributes collection is populated with the MDN data.

#[attributes.MDNReceiptHeaders] #[attributes.MDNReceipt] #[attributes.MDNReceiptDeliveryOption]

Of course, you can save this information and complete the AS2 response out-of-band using the desired mechanisms.

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at