Skip to main content
Package: com.helger.phase4.cef
Maven artifact: com.helger.phase4:phase4-cef-client
Phase4CEFSender sends AS4 messages conforming to the CEF four-corner profile, using OASIS BDXR SMP v1 or v2 for dynamic discovery.

Factory method

Phase4CEFSender.CEFUserMessageBuilder builder = Phase4CEFSender.builder();

CEFUserMessageBuilder

Required fields

body.senderParticipantID
IParticipantIdentifier
required
Participant ID of the sender. Ends up as the originalSender user message property.
body.receiverParticipantID
IParticipantIdentifier
required
Participant ID of the receiver. Ends up as the finalRecipient user message property.
body.documentTypeID
IDocumentTypeIdentifier
required
Document type identifier. Automatically sets the action field.
body.processID
IProcessIdentifier
required
Process identifier. Automatically sets the service fields.
body.fromPartyID(IParticipantIdentifier)
IParticipantIdentifier
required
The sender’s AS4 party ID. Sets both type (scheme) and value.
body.toPartyID(IParticipantIdentifier)
IParticipantIdentifier
required
The receiver’s AS4 party ID. Sets both type (scheme) and value.
body.payload
AS4OutgoingAttachment
required
The payload to send.
body.endpointDetailProvider
IAS4EndpointDetailProvider
required
Endpoint discovery mechanism. Use smpClient() or receiverEndpointDetails().

Endpoint discovery

body.smpClient(IBDXRExtendedServiceMetadataProvider)
IBDXRExtendedServiceMetadataProvider
OASIS BDXR SMP v1 client for dynamic endpoint lookup.
body.smpClient(IBDXR2ServiceMetadataProvider)
IBDXR2ServiceMetadataProvider
OASIS BDXR SMP v2 client for dynamic endpoint lookup. Since 0.10.6.
body.receiverEndpointDetails(X509Certificate, String)
void
Set endpoint statically: provide the receiver certificate and destination URL directly.

Optional fields

body.certificateConsumer
Consumer<X509Certificate>
Optional callback invoked with the resolved receiver AP certificate.
body.endointURLConsumer
Consumer<String>
Optional callback invoked with the resolved AP endpoint URL.
body.useOriginalSenderFinalRecipientTypeAttr
boolean
default:"true"
Controls whether the type attribute on the originalSender and finalRecipient user message properties is emitted. Since 0.10.3.

Example

import com.helger.phase4.cef.Phase4CEFSender;
import com.helger.peppolid.factory.SimpleIdentifierFactory;
import com.helger.smpclient.bdxr1.BDXRClientReadOnly;

SimpleIdentifierFactory IF = Phase4CEFSender.IF;

BDXRClientReadOnly smpClient = new BDXRClientReadOnly(smpBaseURI);

EAS4UserMessageSendResult result = Phase4CEFSender.builder()
    .cryptoFactorySign(cryptoFactory)
    .cryptoFactoryCrypt(cryptoFactory)
    .senderParticipantID(IF.createParticipantIdentifier("urn:oasis:names:tc:ebcore:partyid-type:unregistered", "sender"))
    .receiverParticipantID(IF.createParticipantIdentifier("urn:oasis:names:tc:ebcore:partyid-type:unregistered", "receiver"))
    .documentTypeID(IF.createDocumentTypeIdentifier("doctype", "urn:example:doc"))
    .processID(IF.createProcessIdentifier("cenbii-procid-ubl", "urn:www.cenbii.eu:profile:bii04:ver2.0"))
    .fromPartyID(IF.createParticipantIdentifier("urn:oasis:names:tc:ebcore:partyid-type:unregistered", "sender"))
    .toPartyID(IF.createParticipantIdentifier("urn:oasis:names:tc:ebcore:partyid-type:unregistered", "receiver"))
    .fromRole(CAS4.DEFAULT_INITIATOR_URL)
    .toRole(CAS4.DEFAULT_RESPONDER_URL)
    .smpClient(smpClient)
    .payload(AS4OutgoingAttachment.builder()
        .data(payloadBytes)
        .mimeType(CMimeType.APPLICATION_XML)
        .build())
    .sendMessageAndCheckForReceipt();

Build docs developers (and LLMs) love