What is a PMode?
A Processing Mode (PMode) is the central configuration object in AS4. It describes the complete rules governing a message exchange between two parties:- Which parties are communicating and what roles they play
- The MEP (One-Way/Push, Two-Way, One-Way/Pull)
- The SOAP version and endpoint URL
- Security settings (signing algorithm, encryption algorithm, receipt)
- Business information (service, action, MPC)
- Reliability and error handling behavior
PMode structure
ThePMode class (implementing IPMode) has the following top-level fields:
| Field | Type | Description |
|---|---|---|
| ID | String | Unique PMode identifier |
| Initiator | PModeParty | The party that initiates the MEP |
| Responder | PModeParty | The party that responds |
| Agreement | String | Optional agreement reference (eb:AgreementRef) |
| MEP | EMEP | Message exchange pattern (ONE_WAY or TWO_WAY) |
| MEPBinding | EMEPBinding | Transport binding (PUSH, PULL, etc.) |
| Leg1 | PModeLeg | Configuration for the first (or only) message leg |
| Leg2 | PModeLeg | Configuration for the second leg (Two-Way only) |
| PayloadService | PModePayloadService | Optional payload compression settings |
| ReceptionAwareness | PModeReceptionAwareness | Retry and duplicate detection settings |
PModeParty
PModeParty represents one endpoint in a PMode. It holds the party identifier, role, and optional WS-Security username/password credentials.
PModeLeg
EachPModeLeg contains five sub-components:
| Sub-component | Class | Description |
|---|---|---|
| Protocol | PModeLegProtocol | SOAP version and endpoint address |
| Business info | PModeLegBusinessInformation | Service, action, MPC, payload profiles |
| Error handling | PModeLegErrorHandling | How to report errors |
| Reliability | PModeLegReliability | Duplicate detection and retry |
| Security | PModeLegSecurity | WS-Security signing and encryption |
Creating a PMode
PMode managers
phase4 ships twoIPModeManager implementations:
PModeManagerInMemory
Stores PModes in a
HashMap. Suitable for applications that create PModes programmatically at startup. PModes are lost when the application restarts.PModeManagerXML
Persists PModes to an XML file using the phoss DAO layer. PModes survive restarts and can be edited externally.
Default PMode
DefaultPMode provides a fallback One-Way/Push PMode that conforms to the base ebMS 3.0 specification with no profile-specific constraints. It is useful for testing or as a starting point before adopting a specific profile.
EMEP.ONE_WAY+EMEPBinding.PUSHESoapVersion.AS4_DEFAULT(SOAP 1.2)- Receipt enabled with synchronous reply pattern
- ID type
"default"for both parties
How PModes are resolved for incoming messages
When phase4 receives an AS4 message it matches the message against registered PModes in the following order:- Extract the initiator party ID and responder party ID from the
eb:PartyInfoelement. - Extract the service and action from
eb:CollaborationInfo. - Call
IPModeManager.findPModeByID(...)— exact match by PMode ID if present in the message. - Fall back to a linear scan of all registered PModes, applying the profile-specific
IAS4ProfileValidatorif one is configured.
Profile modules such as
phase4-profile-peppol override the default PMode resolution with their own logic, matching on party identifiers, service type, and action values defined by the profile specification.Reading PMode fields
TheIPMode interface exposes read-only accessors for all fields: