KB Article #180465

AS2: Configuring asynchronous MDN receipts

AS2 and asynchronous MDN receipts

The AS2 protocol is a special protocol which - in the general case - requires a bi-directional partnership to be created - you define the partner's server on your side, and the partner defines your server on theirs. This opens several use cases with this partnership and the AS2 MDN receipts configuration differs depending on the actual usage.


It is possible to use the partnership only in one direction - to send files to a partner or receive files from them (essentially they are sending to you). In this case the the AS2-MDN has to be configured only for one side of the partnership.


To be able to send and receive files to/from a partner and accordingly the asynchronous AS2-MDN receipts have to be configured on both ends, both for inbound and outbound directions.


The asynchronous AS2-MDN receipt is sent in a separate HTTP or HTTPS TCP/IP connection and is similar to an inbound transfer from a partner.


In ST, the setup that handles AS2 transfers can be an instance of the Site Mailbox, the Basic Application or the Advanced Routing application types. A user account has to be subscribed to one of those to be able to send and/or receive files over AS2, and this article describes the steps to configure each one of them.



Site Mailbox

Design: Uses one Subscription to a Site Mailbox application to handle both inbound and outbound transfers


Elements:


  • One AS2 Transfer Site (in the user account)
  • A Site Mailbox application
  • One Subscription (in the user account)
  • Allows both sending and receiving files


The Site Mailbox Subscription



A successful AS2 transfer with asynchronous AS2 - MDN and Site Mailbox application






Basic Application

Design: Uses Basic application and two subscriptions associated with the AS2 transfer site. One for sent and one for receive.


Elements:


  • One AS2 Transfer Site (in the user account)
  • A Basic application (essentially used twice)
  • One Subscription with the AS2 Site for the inbound
  • One Subscription with the AS2 Site for the outbound


The outbound Basic Application Subscription



The inbound Basic Application Subscription



A successful AS2 transfer with asynchronous AS2 - MDN and Basic application






Advanced Routing

The Advanced Routing a very powerful tool to process files, but it has an inherent drawback - the configuration for the outbound direction is not in the Subscription, but in the Routes. This presents a problem for AS2 transfers and the asynchronous MDNs due to the way ST relates the received receipts to the transfers - via the Subscription. In the above two cases - Site Mailbox and Basic Application - the Subscription holds the config for the outbound transfers, so when ST receives an MDN it is able to find the proper subscription and validate the MDN.


With Advanced Routing this is not so and when a file was sent to partner via AS2 in a Route, and the MDN is returned by the partner, ST is unable to locate the Subscription the MDN belongs to and throws an error:


org.openas2.partner.PartnershipNotFoundException: AS2 site <AS2-sitename> is not used for sending in any subscription.


This is a direct consequence of the design of the Advanced Routing and is not an ST application defect; one could say it's expected. However, this deficiency makes it necessary to resolve to complex workarounds in order to use AS2 Transfer Sites in Advanced Routing applications when asynchronous MDNs are required. The below points will outline the available workarounds.


Workaround 1


This approach uses a hybrid of an Advanced Routing instance and one Subscription from the Basic Application section above.


Design: Use Advanced Routing to receive the files and process (send) them with an AS2 Site. A dummy Basic Application will be added (and subscribed to a different folder) which will bridge the gap between the AR-sent file and the MDN in ST. In essence, the Advanced Routing will be used to send the files, while the Basic Application will be only for receiving the asynchronous MDNs.


Elements:


  • One AS2 Transfer Site (in the user account)
  • An Advanced Routing instance with a Route that uses an AS2 Transfer Site to send the files in a Send To Partner step. This instance will be subscribed in a dedicated folder, using the same AS2 Transfer Site selected in the Automatically receive files from section.
  • A Basic application, using the same AS2 Transfer Site selected in the Send files directly to section, which will be subscribed in a second, different folder.


This setup is good only for outbound transfers with asynchronous AS2-MDN. If your partner sends you an AS2 message (a file) you will return it back to them as the Route will be triggered from the AR subscription. This problem can be avoided if the route in the subscription shown below sends the file to internal server instead of partner AS2 Transfer Site in Advanced Routing Send To Partner step. To send files outbound in this case you need another Advanced Routing instance with a route that uses an AS2 Transfer Site to send the files in a Send To Partner step, but without specifying Automatically retrieve files from section.


The Advanced Router Subscription



Note that the dummy Basic Application subscription is the same as in the Basic Application section above. Even though the AS2 Site is selected in the Send files directly to section, this is not practically used to send files!



Workaround 2


This is a combination of Workaround 1 and the full Basic Application section above.


Design: Use Advanced Routing in one Subscription, and two (dummy) Subscriptions with Basic Application. Each of the three is subscribed to a separate folder once again. The AR is used to do the actual file transfers, while one of the BA Subscriptions is used to receive the files, while the other one is taking care of receiving the asynchronous MDNs and "bridging the gap" between the MDNs and the Subscriptions.


Elements:


  • One AS2 Transfer Site (in the user account)
  • An Advanced Routing instance with a Route that uses an AS2 Transfer Site to send the files in a Send To Partner step. This instance will be subscribed in a dedicated folder
  • A Basic application, using the same AS2 Transfer Site selected in the Send files directly to section, which will be subscribed in a second, different folder
  • A Basic application, using the same AS2 Transfer Site selected in the Automatically receive files from section, which will be subscribed in a third, different folder


The Advanced Router Subscription



The outbound Basic Application Subscription



The inbound Basic Application Subscription for receiving the MDNs



All three Subscriptions and their separate folders



Workaround 3


This is a variant of Workaround 2 with the full Site Mailbox section above.


Design: Use Advanced Routing in one Subscription. A dummy Site Mailbox will be added (and subscribed to a different folder) which will bridge the gap between the AR-sent file and the MDN in ST. In essence, the Advanced Routing will be used to send the files, while the Site Mailbox will be only for receiving the files and the asynchronous MDNs (and bridging the gap).


Elements:


  • One AS2 Transfer Site (in the user account)
  • An Advanced Routing instance with a Route that uses an AS2 Transfer Site to send the files in a Send To Partner step. This instance will be subscribed in a dedicated folder
  • A Site Mailbox application, using the same AS2 Transfer Site selected in the Send files directly to and Automatically receive files from sections, which will be subscribed in a second, different folder


The Advanced Router Subscription



The Site Mailbox Subscription



A successful AS2 transfer with asynchronous AS2 - MDN and Advanced Routing application





Conclusion


Workarounds #2 and #3 are the best setup for sending and receiving files via AS2 protocol and using Advanced Routing application. The AR Subscription is used to send the files and the Site Mailbox or Basic Application Subscriptions are used to create the partnerships - to receive the files, the MDNs and to help ST relate the receipts to the Subscriptions.


Workaround #1 is good only for sending files over AS2 with asynchronous AS2-MDN. The setup is not good for receiving files and it has a side effect that the received files will be sent back to the partner via the AR Subscription. There is a solution for this problem, which is described in red text above.