Skip to main content
Package: com.helger.phase4.bdew
Maven artifact: com.helger.phase4:phase4-bdew-client
Phase4BDEWSender sends AS4 messages conforming to the German BDEW energy market profile. The builder sets BDEW-specific defaults automatically (ECDH-ES key transport, BST Direct Reference signing, forced MIME message).

Factory method

Phase4BDEWSender.BDEWUserMessageBuilder builder = Phase4BDEWSender.builder();

Default settings applied by the builder

SettingValue
AS4 profilebdew
Key identifier type (sign)BST_DIRECT_REFERENCE
Key identifier type (crypt)X509_SKI_KEY_IDENTIFIER
Key encryption algorithmECDH_ES_KEYWRAP_AES_128
Encrypt symmetric session keyfalse
C14N algorithmExclusive C14N without comments
BST value type#X509PKIPathv1 (chain)
Conversation ID"" (empty, must not be changed)
Agreement refBDEW default agreement ID
Force MIME messagetrue

BDEWUserMessageBuilder fields

Required fields

body.fromPartyID
String
required
The sender AS4 party ID value.
body.fromRole
String
required
The sender role.
body.toPartyID
String
required
The receiver AS4 party ID value.
body.toRole
String
required
The receiver role.
body.endpointURL
String
required
The destination AS4 endpoint URL.
body.payload(AS4OutgoingAttachment.Builder, BDEWPayloadParams)
AS4OutgoingAttachment.Builder
required
Set the payload. GZip compression is automatically applied. Optionally pass BDEWPayloadParams for BDEW-specific MIME part properties.

Crypto overrides

body.encryptionKeyIdentifierType
ECryptoKeyIdentifierType
Override the default encryption key identifier type (X509_SKI_KEY_IDENTIFIER).
body.signingKeyIdentifierType
ECryptoKeyIdentifierType
Override the default signing key identifier type (BST_DIRECT_REFERENCE).

BDEWPayloadParams

Optional BDEW-specific part properties added to the payload MIME part.
body.setDocumentType
String
BDEW document type string. Set as BDEWDocumentType MIME part property.
body.setDocumentDate
LocalDate
Document date. Set as BDEWDocumentDate MIME part property.
body.setDocumentNumber(String)
String
Document number. Set as BDEWDocumentNo MIME part property.
body.setDocumentNumber(int)
int
Document number as integer, converted to string. Since 2.1.2.
body.setFulfillmentDate
LocalDate
Fulfillment date. Set as BDEWFulfillmentDate MIME part property.
body.setSubjectPartyId
String
Subject party ID. Set as BDEWSubjectPartyID MIME part property.
body.setSubjectPartyRole
String
Subject party role. Set as BDEWSubjectPartyRole MIME part property.
body.setApplicationReference
String
Application reference. Set as BDEWApplicationReference MIME part property. Since 3.0.1.

Example

import com.helger.phase4.bdew.Phase4BDEWSender;
import com.helger.phase4.attachment.AS4OutgoingAttachment;
import java.time.LocalDate;

Phase4BDEWSender.BDEWPayloadParams payloadParams =
    new Phase4BDEWSender.BDEWPayloadParams()
        .setDocumentType("UTILMD")
        .setDocumentDate(LocalDate.now())
        .setDocumentNumber("1001");

EAS4UserMessageSendResult result = Phase4BDEWSender.builder()
    .cryptoFactorySign(cryptoFactory)
    .cryptoFactoryCrypt(cryptoFactory)
    .fromPartyID("9912345678901")
    .fromRole("urn:bdew.de:as4:scheme:MSB")
    .toPartyID("9900000000001")
    .toRole("urn:bdew.de:as4:scheme:LF")
    .endpointURL("https://receiver.example.com/as4")
    .receiverCertificate(receiverCert)
    .service("urn:bdew.de:as4:service:energymarket")
    .action("urn:bdew.de:as4:action:metering")
    .payload(
        AS4OutgoingAttachment.builder()
            .data(ediMessageBytes)
            .mimeTypeText(),
        payloadParams
    )
    .sendMessageAndCheckForReceipt();

Build docs developers (and LLMs) love