Send AS4 messages to the Peppol network using Phase4PeppolSender with automatic SBDH creation, SMP lookup, and AP certificate validation.
Phase4PeppolSender wraps all Peppol-specific AS4 requirements: Standard Business Document Header (SBDH) creation, SMP-based dynamic discovery, AP certificate validity checks, and the correct Peppol PMode and crypto parameters.
By default, phase4 validates the receiver’s AP certificate against the Peppol CA chain. This checks certificate validity and OCSP revocation status.
Phase4PeppolSender.builder() // Use the test CA for the Peppol test environment .peppolAP_CAChecker(PeppolTrustedCA.peppolTestAP()) // Inspect the certificate check result .certificateConsumer((aCert, aCheckTime, eCheckResult) -> { LOGGER.info("AP certificate check: " + eCheckResult); }) // Disable the check entirely (not recommended for production) // .checkReceiverAPCertificate(false) ...
Certificate validation is enabled by default and is strongly recommended for production use. Disabling it means you cannot verify that messages go to a legitimate Peppol Access Point.
The PeppolUserMessageBuilder can validate the business document before building the SBDH:
import com.helger.phive.peppol.PeppolValidation2025_11;// Use the default validation result handler (throws on error).validationConfiguration(PeppolValidation2025_11.VID_OPENPEPPOL_INVOICE_UBL_V3)// Provide a custom result handler.validationConfiguration( PeppolValidation2025_11.VID_OPENPEPPOL_INVOICE_UBL_V3, new Phase4PeppolValidatonResultHandler() { @Override public void onValidationSuccess(final ValidationResultList aResult) { LOGGER.info("Document is valid"); } })// Disable validation entirely.disableValidation()
Validation only works with Phase4PeppolSender.builder(), not with sbdhBuilder() (the SBDH is assumed to be pre-validated).
After a successful send you can create a Peppol Reporting item:
final Phase4PeppolSender.PeppolUserMessageBuilder aBuilder = Phase4PeppolSender.builder() ...;final EAS4UserMessageSendResult eResult = aBuilder.sendMessageAndCheckForReceipt();if (eResult.isSuccess()) { // Create and store reporting item in one step aBuilder.createAndStorePeppolReportingItemAfterSending("myEndUserID");}
Phase4PeppolSender.builder() // Override the SBDH instance identifier (useful for retries) .sbdhInstanceIdentifier("same-uuid-as-original-send") // Log the endpoint URL that was resolved .endpointURLConsumer(url -> LOGGER.info("Sending to: " + url)) // Log the technical contact from the SMP record .technicalContactConsumer(contact -> LOGGER.info("Technical contact: " + contact)) // Log the resolved AP certificate .certificateConsumer((cert, time, result) -> ...) // Custom payload Content-ID header .payloadContentID("[email protected]") ...