AS2

Since Camel 2.22

Both producer and consumer are supported

The AS2 component provides transport of EDI messages using the HTTP transfer protocol as specified in RFC4130.

This component is currently a work in progress. Expect URI options and path and query parameters to change in future versions of this component.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-as2</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

as2://apiName/methodName

apiName can be one of:

  • client

  • server

AS2 Options

The AS2 component supports 4 options, which are listed below.

Name Description Default Type

bridgeErrorHandler (consumer)

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

boolean

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

configuration (advanced)

Component configuration

AS2Configuration

The AS2 endpoint is configured using URI syntax:

as2:apiName/methodName

with the following path and query parameters:

Path Parameters (2 parameters):

Name Description Default Type

apiName

Required What kind of operation to perform. There are 2 enums and the value can be one of: CLIENT, SERVER

AS2ApiName

methodName

Required What sub operation to use for the selected operation

String

Query Parameters (31 parameters):

Name Description Default Type

as2From (common)

The value of the AS2From header of AS2 message.

String

as2MessageStructure (common)

The structure of AS2 Message. One of: PLAIN - No encryption, no signature, SIGNED - No encryption, signature, ENCRYPTED - Encryption, no signature, ENCRYPTED_SIGNED - Encryption, signature. There are 8 enums and the value can be one of: PLAIN, SIGNED, ENCRYPTED, SIGNED_ENCRYPTED, PLAIN_COMPRESSED, SIGNED_COMPRESSED, ENCRYPTED_COMPRESSED, ENCRYPTED_COMPRESSED_SIGNED

AS2MessageStructure

as2To (common)

The value of the AS2To header of AS2 message.

String

as2Version (common)

The version of the AS2 protocol. There are 2 enums and the value can be one of: 1.0, 1.1

1.1

String

clientFqdn (common)

The Client Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint.

camel.apache.org

String

compressionAlgorithm (common)

The algorithm used to compress EDI message. There are 1 enums and the value can be one of: ZLIB

AS2CompressionAlgorithm

decryptingPrivateKey (common)

The key used to encrypt the EDI message.

PrivateKey

dispositionNotificationTo (common)

The value of the Disposition-Notification-To header. Assigning a value to this parameter requests a message disposition notification (MDN) for the AS2 message.

String

ediMessageTransferEncoding (common)

The transfer encoding of EDI message.

String

ediMessageType (common)

The content type of EDI message. One of application/edifact, application/edi-x12, application/edi-consent

ContentType

encryptingAlgorithm (common)

The algorithm used to encrypt EDI message. There are 20 enums and the value can be one of: AES128_CBC, AES192_CBC, AES256_CBC, AES128_CCM, AES192_CCM, AES256_CCM, AES128_GCM, AES192_GCM, AES256_GCM, CAMELLIA128_CBC, CAMELLIA192_CBC, CAMELLIA256_CBC, CAST5_CBC, DES_CBC, DES_EDE3_CBC, GOST28147_GCFB, IDEA_CBC, RC2_CBC, RC4, SEED_CBC

AS2EncryptionAlgorithm

encryptingCertificateChain (common)

The chain of certificates used to encrypt EDI message.

Certificate[]

from (common)

The value of the From header of AS2 message.

String

inBody (common)

Sets the name of a parameter to be passed in the exchange In Body

String

mdnMessageTemplate (common)

The template used to format MDN message

String

requestUri (common)

The request URI of EDI message.

/

String

server (common)

The value included in the Server message header identifying the AS2 Server.

Camel AS2 Server Endpoint

String

serverFqdn (common)

The Server Fully Qualified Domain Name (FQDN). Used in message ids sent by endpoint.

camel.apache.org

String

serverPortNumber (common)

The port number of server.

Integer

signedReceiptMicAlgorithms (common)

The list of algorithms, in order of preference, requested to generate a message integrity check (MIC) returned in message dispostion notification (MDN)

String[]

signingAlgorithm (common)

The algorithm used to sign EDI message. There are 47 enums and the value can be one of: SHA3_224WITHRSA, SHA3_256WITHRSA, SHA3_384withRSA, SHA3_512WITHRSA, MD5WITHRSA, SHA1WITHRSA, MD2WITHRSA, SHA224WITHRSA, SHA256WITHRSA, SHA384WITHRSA, SHA512WITHRSA, RIPEMD128WITHRSA, RIPEMD160WITHRSA, RIPEMD256WITHRSA, SHA224WITHDSA, SHA256WITHDSA, SHA384WITHDSA, SHA512WITHDSA, SHA3_224WITHDSA, SHA3_256WITHDSA, SHA3_384WITHDSA, SHA3_512WITHDSA, SHA1WITHDSA, SHA3_224WITHECDSA, SHA3_256WITHECDSA, SHA3_384WITHECDSA, SHA3_512WITHECDSA, SHA1WITHECDSA, SHA224WITHECDSA, SHA256WITHECDSA, SHA384WITHECDSA, SHA512WITHECDSA, SHA1WITHPLAIN_ECDSA, SHA224WITHPLAIN_ECDSA, SHA256WITHPLAIN_ECDSA, SHA384WITHPLAIN_ECDSA, SHA512WITHPLAIN_ECDSA, RIPEMD160WITHPLAIN_ECDSA, SHA1WITHRSAANDMGF1, SHA224WITHRSAANDMGF1, SHA256WITHRSAANDMGF1, SHA384WITHRSAANDMGF1, SHA512WITHRSAANDMGF1, SHA3_224WITHRSAANDMGF1, SHA3_256WITHRSAANDMGF1, SHA3_384WITHRSAANDMGF1, SHA3_512WITHRSAANDMGF1

AS2SignatureAlgorithm

signingCertificateChain (common)

The chain of certificates used to sign EDI message.

Certificate[]

signingPrivateKey (common)

The key used to sign the EDI message.

PrivateKey

subject (common)

The value of Subject header of AS2 message.

String

targetHostname (common)

The host name (IP or DNS name) of target host.

String

targetPortNumber (common)

The port number of target host. -1 indicates the scheme default port.

Integer

userAgent (common)

The value included in the User-Agent message header identifying the AS2 user agent.

Camel AS2 Client Endpoint

String

exceptionHandler (consumer)

To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored.

ExceptionHandler

exchangePattern (consumer)

Sets the exchange pattern when the consumer creates an exchange. There are 3 enums and the value can be one of: InOnly, InOut, InOptionalOut

ExchangePattern

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

synchronous (advanced)

Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported).

false

boolean

API Parameters (2 APIs):

The AS2 endpoint is an API based component and has additional parameters based on which API name and API method is used. The API name and API method is located in the endpoint URI as the apiName/methodName path parameters:

as2:apiName/methodName

There are 2 API names as listed in the table below:

API Name Type Description

client

Producer

Sends EDI Messages over HTTP

server

Consumer

Receives EDI Messages over HTTP

Each API is documented in the following sections to come.

API: client

Only producer is supported

The client API has 1 method(s) which is represented by the following method signatures (an API method may have multiple signatures due to overloading):

org.apache.http.protocol.HttpCoreContext send(String ediMessage, String requestUri, String subject, String from, String as2From, String as2To, org.apache.camel.component.as2.api.AS2MessageStructure as2MessageStructure, org.apache.http.entity.ContentType ediMessageContentType, String ediMessageTransferEncoding, org.apache.camel.component.as2.api.AS2SignatureAlgorithm signingAlgorithm, java.security.cert.Certificate[] signingCertificateChain, java.security.PrivateKey signingPrivateKey, org.apache.camel.component.as2.api.AS2CompressionAlgorithm compressionAlgorithm, String dispositionNotificationTo, String[] signedReceiptMicAlgorithms, org.apache.camel.component.as2.api.AS2EncryptionAlgorithm encryptingAlgorithm, java.security.cert.Certificate[] encryptingCertificateChain);

The client API is defined in the syntax as follows:

as2:client/methodName?[parameters]

The 1 method(s) is listed in the table below. (API methods can have a shorthand alias name which can be used in the syntax instead of the name)

Method Alias Description

send

Send ediMessage to trading partner

The client API method(s) has the following set of parameters listed in the table below:

Method Parameter Description Type

send

as2From

AS2 name of sender

String

send

as2MessageStructure

The structure of AS2 to send; see AS2MessageStructure

AS2MessageStructure

send

as2To

AS2 name of recipient

String

send

compressionAlgorithm

Optional The algorithm used to compress the message or null if sending EDI message uncompressed

AS2CompressionAlgorithm

send

dispositionNotificationTo

Optional An RFC2822 address to request a receipt or null if no receipt requested

String

send

ediMessage

EDI message to transport

String

send

ediMessageContentType

The content typw of EDI message

ContentType

send

ediMessageTransferEncoding

Optional The transfer encoding used to transport EDI message

String

send

encryptingAlgorithm

Optional The algorithm used to encrypt the message or null if sending EDI message unencrypted

AS2EncryptionAlgorithm

send

encryptingCertificateChain

Optional The chain of certificates used to encrypt the message or null if sending EDI message unencrypted

Certificate[]

send

from

RFC2822 address of sender

String

send

requestUri

Resource location to deliver message

String

send

signedReceiptMicAlgorithms

Optional The senders list of signing algorithms for signing receipt, in preferred order, or null if requesting an unsigned receipt.

String[]

send

signingAlgorithm

Optional The algorithm used to sign the message or null if sending EDI message unsigned

AS2SignatureAlgorithm

send

signingCertificateChain

Optional The chain of certificates used to sign the message or null if sending EDI message unsigned

Certificate[]

send

signingPrivateKey

Optional The private key used to sign EDI message

PrivateKey

send

subject

Message subject

String

In addition to the parameters above, the client API can also use from the 31 endpoint query option which is listed in the Query Parameters section.

Any of the parameters can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelAs2.parameter. The inBody parameter overrides message header, i.e. the endpoint parameter inBody=myParameterNameHere would override a CamelAs2.myParameterNameHere header.

API: server

Only consumer is supported

The server API has 1 method(s) which is represented by the following method signatures (an API method may have multiple signatures due to overloading):

void listen(String requestUriPattern, org.apache.http.protocol.HttpRequestHandler handler);

The server API is defined in the syntax as follows:

as2:server/methodName?[parameters]

The 1 method(s) is listed in the table below. (API methods can have a shorthand alias name which can be used in the syntax instead of the name)

Method Alias Description

listen

The server API method(s) has the following set of parameters listed in the table below:

Method Parameter Description Type

listen

requestUriPattern

String

In addition to the parameters above, the server API can also use from the 31 endpoint query option which is listed in the Query Parameters section.

Any of the parameters can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format CamelAs2.parameter. The inBody parameter overrides message header, i.e. the endpoint parameter inBody=myParameterNameHere would override a CamelAs2.myParameterNameHere header.

Spring Boot Auto-Configuration

When using as2 with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-as2-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 5 options, which are listed below.

Name Description Default Type

camel.component.as2.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.as2.bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.

false

Boolean

camel.component.as2.configuration

Component configuration. The option is a org.apache.camel.component.as2.AS2Configuration type.

AS2Configuration

camel.component.as2.enabled

Whether to enable auto configuration of the as2 component. This is enabled by default.

Boolean

camel.component.as2.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean