Getting started with AS4 and AS4Web for MuleSoft

Requirements: /n software Connectors for MuleSoft

Introduction

The /n software Connectors for MuleSoft are pure java Connectors which integrate directly into AnyPoint Studio (and your Mule application). The /n software Connectors for MuleSoft extend the functionality of MuleSoft and provide robust enterprise-ready Internet connectivity, secure messaging, and file transfer.

Our AS4 Send module handles sending outgoing AS4 messages and our AS4 Receive module will establish a connection to a server and request messages to download from the specified Message Partition Channel (MPC). There are many different connectors currently supported: AS4 for EDI, FTPS, FTP, SFTP, SSH, Email adapters, etc. For details on installation and other connectors please see the Online Documentation.

This guide will walk through configuration of AS4 Send, AS4 Receive and AS4 Web Receive. In most cases configuration is as simple as setting a few properties.

Contents

AS4 Receive Module

The AS4 Receive module will connect to a server and request files to download. It will poll the remote machine and bring files into your flow. The below properties are necessary to connect and make download requests.

Core Properties

PropertyDescription
MPCThe Message Partition Channel from which files are requested.
URLThe partner's URL to which the request is made.
SendReceiptWhether an asynchronous receipt or no receipt should be sent after downloading (Default True).
Decryption CertThe certificate with private key used to decrypt an incoming AS4 message.
Signer CertThe public certificate used to verify the signature of the incoming message.
Signing Cert The certificate with private key used to sign outgoing messages and receipts. In many cases this is the same as Decryption Cert.
SSL Accept Server Cert Optionally specifies a server's SSL certificate to unconditionally accept during TLS negotiation. In test environments an easy way to trust the server certificates is to set the Accept Any field to True. This will implicitly trust the remote host and no further fields should be specified.

To set the fields of certificate properties, the corresponding dropdown should be set to Edit inline. The Store Type, Store, Store Password, and Subject fields together identify the certificate within a certificate store.

An example AS4 Receive certificate configuration

AS4 Receive Usage

The AS4 Receive module is a source module, meaning it is responsible for producing Mule events (like most of our other Receive modules). It's up to you to specify further modules to transform the received data or store it.

There are two main steps to get up and running with AS4 Receive. First, drag an instance of the module from the Mule Palette into your project's Flow designer. This will automatically establish an AS4 Receive module in a flow. Second, apply a configuration to the connector including the core and certificate properties mentioned in the previous section.

An example AS4 Receive flow and configuration

In this case, the connector will produce one mule event for each file downloaded from the server. Each mule event will contain attributes about the file such as AS2FromId, AS2ToId, EDIType, etc. The file name is provided in the #[attributes.ReceivedFileName] field.

AS4 Send

The AS4 Send module supports transmitting outgoing AS4 messages. Together, the below properties make up the baseline settings necessary for sending an AS4 message.

Core Properties

PropertyDescription
AS4 From IdThe sending party's AS4 Identifier. This will always be your identifier.
AS4 To IdThe receiving party's AS4 Identifier.
URLYour trading partner's URL.
Recipient Certells the connector which public key to use when encrypting the outgoing AS4 message.
Signer Certtells the connector which public key to use when verifying the signature on the incoming message
Signing Certtells the connector which private key to use when signing the outgoing message.
SSL Accept Server Certtells the connector a server certificate to unconditionally accept during TLS negotiation. The easiest approach to trusting server certificates is to set the Accept Any field to True. This will implicitly trust the remote host and no further fields should be specified.

To set the fields of certificate properties, the corresponding dropdown should be set to Edit inline. The Store Type, Store, Store Password, and Subject fields together identify the certificate within a certificate store.

An example AS4 Receive certificate configuration

AS4 Send Usage

There are three main steps to get up and running with AS4 Send. First, drag an instance of the AS4 Send module into a Mule project. This will automatically establish an AS4 Send module in a flow. Second, add in your preferred module to read the EDI data. Third, apply a configuration to the connector including the core and certificate properties mentioned in the previous section.

An example AS4 Send and configuration

When the application starts a source event will produce a Mule message. Later in the flow, the message will be passed to the connector. The connector will take in the EDI Data from the payload of the incoming message and send it to the specified URL. It is entirely up to you how the data is added to the payload (it does not need to be stored on disk).

The EDI data in the payload is sent to the remote machine and the AS4 Send module waits for the receipt. Once the response is received, the output of the connector is a Mule message with additional fields in the #[attributes] collection. These fields can be used to determine the status of the receipt.

As a note, requesting an asynchronous MDN for a message is not supported in AS4 Send/p>

AS4Web Receive Module

The AS4Web Receive module supports processing incoming AS4 push messages (files sent by your trading partner). Together, the below properties make up the baseline settings necessary for processing incoming AS4 messages.

Core Properties

PropertyDescription
Trading partnerThe identity of the AS4 sending entity.
Receiving partnerThe identity of the AS4 receiving entity. This will always be your identity.
SendReceiptDefault True. Whether to send a synchronous receipt or no receipt after processing the incoming message.
Decryption Certtells the connector which private key to use when decrypting an incoming AS4 message.
Signer Certtells the connector which public key to use when verifying the signature on the incoming message
Signing Certtells the connector which private key to use when signing the outgoing message
SSL Accept Server Cert tells the connector a server certificate to unconditionally accept during TLS negotiation. The easiest approach to trusting server certificates is to set the Accept Any field to True. This will implicitly trust the remote host and no further fields should be specified.

To set the fields of certificate properties, the corresponding dropdown should be set to Edit inline. The Store Type, Store, Store Password, and Subject fields together identify the certificate within a certificate store.

An example AS4Web certificate configuraiton

AS4Web Receive Usage

The AS4Web Receive module must use the Mule HTTP Listener as a relay because it does not contain a webserver of its own. In a typical scenario, a HTTP Listener will receive the request and send the response. The AS4Web Receive module acts as the processing engine for incoming AS4 messages or asynchronous MDN's.

There are three main steps to get up and running with AS4Web Receive. First, drag an instance of the module from the Mule Palette into your project's Flow designer. This will automatically establish an AS4Web Receive module in a flow. Second, apply a configuration to the connector including the core and certificate properties mentioned in the previous section.

An example AS4Web Receive configuration

Third, specify HTTP Listener settings to relay the receipt back to the client. After AS4Web Receive is finished processing, the body of the receipt can be found in the #[attributes.ResponseBody] field.

The HTTP Listener must be configured to relay the ResponseBody back to the client. In the Responses tab of the Mule properties page for the HTTP Listener, set the Body to #[attributes.ResponseBody]. Add a new header with the value 'Content-Type' and value attributes.ResponseHeaders.'Content-Type'. That is all that is required to relay the receipt to the client. Here is an example of HTTP Listener configuration to support sending a receipt:

An example HTTP Listener and configuration

Configuration XML:

<http:listener doc:name="Mule HTTP Listener" doc:id="7fc74098-3d3d-41d6-abd6-6e745da04806" config-ref="HTTP_Listener_config" path="as4web">
  <http:response >
    <http:body ><![CDATA[#[attributes.ResponseBody]]]></http:body>
    <http:headers ><![CDATA[#[output application/java
---
{
"Content-Type" : attributes.ResponseHeaders.'Content-Type'
}]]]></http:headers>
  </http:response>
</http:listener>

The received files are available via attributes after AS4Web Receive is finished processing. #[attributes.AS4RecAttributes] is a special attribute consisting of a collection of EDIData entities from the request. Each EDIData has its own attributes, such as EDIProperties, EDISchemaLocation, EDISchemaNamespace, EDISchemaVersion, EDIType and Output. The Mule 'For Each' Scope supports iterating over the collection of EDIData entities.

An example For Each configuration

<foreach doc:name="For Each" doc:id="bca94907-a305-40fc-b818-8909f556564c" collection="#[attributes.AS4RecAttributes]">
  <logger level="INFO" doc:name="Logger" doc:id="0a86f0a7-3e20-4b8f-bb6e-c0a86f9aefc4" message="#[payload.ReceivedFileName]"/>
  <logger level="INFO" doc:name="Logger" doc:id="f77b2a52-997d-414b-a1d2-9f9a15ad0a55" message="#[payload.Output]"/>
</foreach>

Note: The attributes for each EDIData entitiy in AS4RecAttributes is available in the payload of the message within the 'For Each' Scope.

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