Architecture
The receiving stack consists of four layers:HTTP request arrives at the servlet
An HTTP POST request carrying an AS4 message reaches the registered servlet endpoint (typically
/as4).AS4XServletHandler dispatches the request
AS4XServletHandler reads the request stream, creates AS4IncomingMessageMetadata capturing connection metadata, and delegates to AS4RequestHandler.AS4RequestHandler parses and validates
The handler parses the SOAP envelope, verifies the WS-Security signature, decrypts the payload, checks the AS4 profile constraints, detects duplicates, and builds the response (receipt or error signal).
Key classes
| Class / Interface | Role |
|---|---|
AS4Servlet | Thin Jakarta Servlet that wires AS4XServletHandler for HTTP POST |
Phase4PeppolAS4Servlet | Peppol-specific servlet that configures the security customizer automatically |
AS4XServletHandler | Main servlet handler; creates metadata and runs AS4RequestHandler |
IAS4ServletRequestHandlerCustomizer | Optional hook to configure AS4RequestHandler before/after processing |
AS4RequestHandler | Core pipeline: parse → verify → decrypt → profile-check → SPI dispatch |
IAS4IncomingMessageProcessorSPI | SPI interface your application implements to receive user/signal messages |
AS4IncomingMessageMetadata | Transport-level metadata (IP, TLS cert, timestamp) for one incoming request |
AS4ServerInitializer | One-time server bootstrap: registers managers and schedules duplicate cleanup |
The SPI pattern
phase4 usesjava.util.ServiceLoader to discover all IAS4IncomingMessageProcessorSPI implementations on the classpath. To register your implementation, create the file:
Next steps
Servlet setup
Register
AS4Servlet in web.xml and configure AS4XServletHandler.Peppol server
Use
Phase4PeppolAS4Servlet and implement IPhase4PeppolIncomingSBDHandlerSPI.Message processing
Understand the processing lifecycle, metadata, duplicate detection, and error handling.