AS4Sender builder. It assumes you have Java 17 and Maven installed.
Add the dependency
Add See the Installation guide for Gradle syntax and all available modules.
phase4-lib to your Maven pom.xml:pom.xml
Configure your key store
phase4 uses WS-Security for signing and encrypting messages. You need a key store (
.jks or .p12) with your private key.Create an AS4CryptoFactoryInMemoryKeyStore pointing to a loaded KeyStore:Send an AS4 user message
Use
AS4Sender.builderUserMessage() to build and send a generic AS4 user message.
The builder enforces that the payload is placed as a MIME attachment rather than
inline in the SOAP body.sendMessageAndCheckForReceipt() returns EAS4UserMessageSendResult.SUCCESS only
when the remote endpoint returns a positive AS4 Receipt signal message.Handle the result
EAS4UserMessageSendResult has several outcome values:| Value | Meaning |
|---|---|
SUCCESS | Receipt received — delivery confirmed |
INVALID_PARAMETERS | A required builder field was not set |
TRANSPORT_ERROR | Network or HTTP(S) failure; retry may help |
TRANSPORT_ERROR_NO_RETRY | Network failure where retry is not feasible |
NO_SIGNAL_MESSAGE_RECEIVED | Response was not a valid AS4 Signal Message |
AS4_ERROR_MESSAGE_RECEIVED | Remote endpoint returned an AS4 Error Message |
INVALID_SIGNAL_MESSAGE_RECEIVED | Signal message had neither a receipt nor errors |
result.isRetryFeasible() to decide whether to attempt a retry when the
built-in HTTP retry mechanism is disabled.Next steps
Installation
All modules, Maven BOM, and Gradle snippets
Crypto setup
Configure signing and encryption in detail
Sending Peppol messages
High-level Peppol sender with dynamic SMP discovery
Generic AS4 sending
Full reference for all builder options