Package com.helger.phase4.client
Class AS4ClientUserMessage
java.lang.Object
com.helger.phase4.client.AbstractAS4Client<AS4ClientUserMessage>
com.helger.phase4.client.AS4ClientUserMessage
- All Implemented Interfaces:
com.helger.base.trait.IGenericImplTrait<AS4ClientUserMessage>
AS4 client for
AS4UserMessage objects.- Author:
- Philip Helger, bayerlma
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal @NonNull AS4ClientUserMessageaddAttachment(@NonNull WSS4JAttachment aAttachment) Adds a file as attachment to the message.final @NonNull AS4ClientUserMessageaddAttachment(@NonNull File aAttachment, @NonNull com.helger.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eAS4CompressionMode) Adds a file as attachment to the message.final @NonNull com.helger.collection.commons.ICommonsList<WSS4JAttachment> @NonNull AS4ClientBuiltMessagebuildMessage(@NonNull @Nonempty String sMessageID, @Nullable IAS4ClientBuildMessageCallback aCallback) Build the AS4 message to be sent.final @NonNull com.helger.collection.commons.ICommonsList<Ebms3Property> With properties optional info can be added for the receiving party.final @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Nodefinal @Nullable IPModegetPMode()final @NonNull Function<AS4ClientUserMessage, String> final @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal @Nullable Stringfinal booleanfinal booleanfinal @NonNull AS4ClientUserMessageThe element is a string identifying an operation or an activity within a Service that may support several of these.
Example of what will be written in the user message:<eb:Action>NewPurchaseOrder</eb:Action>
This is MANDATORY.final @NonNull AS4ClientUserMessagesetAgreementRefValue(@Nullable String sAgreementRefValue) The AgreementRef element is a string that identifies the entity or artifact governing the exchange of messages between the parties.
Example of what will be written in the user message:<eb:AgreementRef pmode= "pm-esens-generic-resp">http://agreements.holodeckb2b.org/examples/agreement0</eb:AgreementRef>
This is MANDATORY.final @NonNull AS4ClientUserMessagesetAgreementTypeValue(@Nullable String sAgreementTypeValue) Set the value of theeb:AgreementRef/@typeattribute.final @NonNull AS4ClientUserMessagesetConversationID(@Nullable String sConversationID) The element is a string identifying the set of related messages that make up a conversation between Parties.
Example of what will be written in the user message:<eb:ConversationId>4321</eb:ConversationId>
This is MANDATORY.final @NonNull AS4ClientUserMessagesetForceMimeMessage(boolean bForceMimeMessage) Enable the enforcement of packaging the AS4 user message in a MIME message.final @NonNull AS4ClientUserMessagesetFromPartyID(@Nullable String sFromPartyID) The PartyID is an ID that identifies the C2 over which the message gets sent.
Example of what will be written in the user message:<eb:PartyId>ImAPartyID</eb:PartyId>
This is MANDATORY.final @NonNull AS4ClientUserMessagesetFromPartyIDType(@Nullable String sFromPartyIDType) The PartyID is an ID that identifies the C2 over which the message gets sent.final @NonNull AS4ClientUserMessagesetFromRole(@Nullable String sFromRole) The value of the Role element is a non-empty string, with a default value ofhttp://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/defaultRole.final @NonNull AS4ClientUserMessagesetPayload(@Nullable Node aPayload) Sets the payload for a usermessage.final voidThis method should be used if you do not want to set each parameter and have a PMode ready that you wish to use.final @NonNull AS4ClientUserMessagesetPModeID(@Nullable String sPModeID) final @NonNull AS4ClientUserMessagesetPModeIDFactory(@NonNull Function<AS4ClientUserMessage, String> aPModeIDFactory) final @NonNull AS4ClientUserMessagesetServiceType(@Nullable String sServiceType) It is a string identifying the service type of the service specified in service value.
Example of what will be written in the user message:<eb:Service type= "MyServiceTypes">QuoteToCollect</eb:Service>final @NonNull AS4ClientUserMessagesetServiceValue(@Nullable String sServiceValue) It is a string identifying the service that acts on the message 1639 and it is specified by the designer of the service.
Example of what will be written in the user message:<eb:Service type="MyServiceTypes">QuoteToCollect</eb:Service>
This is MANDATORY.final @NonNull AS4ClientUserMessagesetToPartyID(@Nullable String sToPartyID) * @see #setFromPartyID(String)final @NonNull AS4ClientUserMessagesetToPartyIDType(@Nullable String sToPartyIDType) * @see #setFromPartyIDType(String)final @NonNull AS4ClientUserMessagefinal @NonNull AS4ClientUserMessagesetUseLeg1(boolean bUseLeg1) DEFAULT is set totrue, if you want to use leg2 for the message setfalse.final voidsetUserMessageValuesFromPMode(@NonNull IPMode aPMode, @NonNull PModeLeg aEffectiveLeg) Methods inherited from class com.helger.phase4.client.AbstractAS4Client
createDefaultMessageIDFactory, createMessageID, cryptParams, ensureSendingDateTime, getAS4ResourceHelper, getCryptoFactoryCrypt, getCryptoFactorySign, getHttpPoster, getMessageIDFactory, getMessageType, getRefToMessageID, getSendingDateTime, getSoapVersion, hasRefToMessageID, httpRetrySettings, internalGetCryptoFactoryCrypt, internalGetCryptoFactorySign, sendMessageWithRetries, setCryptoFactory, setCryptoFactoryCrypt, setCryptoFactorySign, setHttpPoster, setMessageID, setMessageIDFactory, setRefToMessageID, setSendingDateTime, setSoapVersion, setValuesFromPMode, signingParamsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.base.trait.IGenericImplTrait
thisAsT
-
Field Details
-
DEFAULT_FORCE_MIME_MESSAGE
public static final boolean DEFAULT_FORCE_MIME_MESSAGE- See Also:
-
-
Constructor Details
-
AS4ClientUserMessage
-
-
Method Details
-
getPayload
- Returns:
- The payload of the user message that will be placed in the SOAP body. May be
null.
-
setPayload
Sets the payload for a usermessage. The payload unlike an attachment will be added into the SOAP-Body of the message.- Parameters:
aPayload- the Payload to be added- Returns:
- this for chaining
-
attachments
@ReturnsMutableObject public final @NonNull com.helger.collection.commons.ICommonsList<WSS4JAttachment> attachments()- Returns:
- The list of attachments that are part of the message. If this list is not empty, a MIME message is created. Having attachments and no SOAP body is totally valid.
-
isForceMimeMessage
public final boolean isForceMimeMessage()- Returns:
trueif a MIME message is always created, even if no attachments are present,falseto use a simple SOAP message in case of absence of attachments. The default value is false- Since:
- 2.5.1
-
setForceMimeMessage
Enable the enforcement of packaging the AS4 user message in a MIME message.- Parameters:
bForceMimeMessage-trueto enforce it,falseto make it dynamic.- Returns:
- this for chaining
- Since:
- 2.5.1
-
addAttachment
public final @NonNull AS4ClientUserMessage addAttachment(@NonNull File aAttachment, @NonNull com.helger.mime.IMimeType aMimeType, @Nullable EAS4CompressionMode eAS4CompressionMode) throws IOException Adds a file as attachment to the message.- Parameters:
aAttachment- Attachment to be added. May not benull.aMimeType- MIME type of the given file. May not benull.eAS4CompressionMode- which compression type should be used to compress the attachment. May benull.- Returns:
- this for chaining
- Throws:
IOException- if something goes wrong in the adding process or the compression
-
addAttachment
Adds a file as attachment to the message. The caller of the method must ensure the attachment is already compressed (if desired)!- Parameters:
aAttachment- Attachment to be added. May not benull.- Returns:
- this for chaining
-
ebms3Properties
@ReturnsMutableObject public final @NonNull com.helger.collection.commons.ICommonsList<Ebms3Property> ebms3Properties()With properties optional info can be added for the receiving party. If you want to be AS4 Profile conform you need to add two properties to your message: originalSender and finalRecipient these two correlate to C1 and C4.- Returns:
- The mutable list. Never
null. - Since:
- 0.8.2
-
getAction
-
setAction
The element is a string identifying an operation or an activity within a Service that may support several of these.
Example of what will be written in the user message:<eb:Action>NewPurchaseOrder</eb:Action>
This is MANDATORY.- Parameters:
sAction- the action that should be there.- Returns:
- this for chaining
-
getServiceType
-
setServiceType
It is a string identifying the service type of the service specified in service value.
Example of what will be written in the user message:<eb:Service type= "MyServiceTypes">QuoteToCollect</eb:Service>- Parameters:
sServiceType- serviceType that should be set- Returns:
- this for chaining
-
getServiceValue
-
setServiceValue
It is a string identifying the service that acts on the message 1639 and it is specified by the designer of the service.
Example of what will be written in the user message:<eb:Service type="MyServiceTypes">QuoteToCollect</eb:Service>
This is MANDATORY.- Parameters:
sServiceValue- the service value that should be set- Returns:
- this for chaining
-
getConversationID
-
setConversationID
The element is a string identifying the set of related messages that make up a conversation between Parties.
Example of what will be written in the user message:<eb:ConversationId>4321</eb:ConversationId>
This is MANDATORY.- Parameters:
sConversationID- the conversationID that should be set- Returns:
- this for chaining
-
getAgreementRefValue
- Returns:
- The value of the
eb:AgreementRefelement. May benull.
-
setAgreementRefValue
public final @NonNull AS4ClientUserMessage setAgreementRefValue(@Nullable String sAgreementRefValue) The AgreementRef element is a string that identifies the entity or artifact governing the exchange of messages between the parties.
Example of what will be written in the user message:<eb:AgreementRef pmode= "pm-esens-generic-resp">http://agreements.holodeckb2b.org/examples/agreement0</eb:AgreementRef>
This is MANDATORY.- Parameters:
sAgreementRefValue- agreement reference that should be set- Returns:
- this for chaining
-
getAgreementTypeValue
- Returns:
- The value of the
eb:AgreementRef/@typeattribute. May benull. - Since:
- 2.7.6
-
setAgreementTypeValue
public final @NonNull AS4ClientUserMessage setAgreementTypeValue(@Nullable String sAgreementTypeValue) Set the value of theeb:AgreementRef/@typeattribute.- Parameters:
sAgreementTypeValue- The value to be set. May benull.- Returns:
- this for chaining
- Since:
- 2.7.6
-
getFromRole
-
setFromRole
The value of the Role element is a non-empty string, with a default value ofhttp://docs.oasis-open.org/ebxml-msg/ebms/v3.0/ns/core/200704/defaultRole.- Parameters:
sFromRole- the role that should be set- Returns:
- this for chaining
-
getFromPartyIDType
-
setFromPartyIDType
The PartyID is an ID that identifies the C2 over which the message gets sent.- Parameters:
sFromPartyIDType- the partyID type that should be set- Returns:
- this for chaining
-
getFromPartyID
-
setFromPartyID
The PartyID is an ID that identifies the C2 over which the message gets sent.
Example of what will be written in the user message:<eb:PartyId>ImAPartyID</eb:PartyId>
This is MANDATORY.- Parameters:
sFromPartyID- the partyID that should be set- Returns:
- this for chaining
-
getToRole
-
setToRole
- Parameters:
sToRole- the role that should be used- Returns:
- this for chaining
- See Also:
-
getToPartyIDType
-
setToPartyIDType
* @see #setFromPartyIDType(String)- Parameters:
sToPartyIDType- the PartyID type that should be set- Returns:
- this for chaining
-
getToPartyID
-
setToPartyID
* @see #setFromPartyID(String)- Parameters:
sToPartyID- the PartyID that should be set- Returns:
- this for chaining
-
isUseLeg1
public final boolean isUseLeg1() -
setUseLeg1
DEFAULT is set totrue, if you want to use leg2 for the message setfalse.- Parameters:
bUseLeg1-trueif leg1 should be used,falseif leg2 should be used- Returns:
- this for chaining
-
getPMode
-
setUserMessageValuesFromPMode
-
setPMode
This method should be used if you do not want to set each parameter and have a PMode ready that you wish to use. Some parameters still must be set with the remaining setters.- Parameters:
aPMode- that should be used. May benullbSetValuesFromPMode-trueto set all values in the client, that can be derived from the PMode,falseto not do it.
-
getPModeIDFactory
-
setPModeID
-
setPModeIDFactory
public final @NonNull AS4ClientUserMessage setPModeIDFactory(@NonNull Function<AS4ClientUserMessage, String> aPModeIDFactory) -
buildMessage
public @NonNull AS4ClientBuiltMessage buildMessage(@Nonempty @NonNull @Nonempty String sMessageID, @Nullable IAS4ClientBuildMessageCallback aCallback) throws org.apache.wss4j.common.ext.WSSecurityException, jakarta.mail.MessagingException Description copied from class:AbstractAS4ClientBuild the AS4 message to be sent. It uses all the attributes of this class to build the final message. Compression, signing and encryption happens in this methods.- Specified by:
buildMessagein classAbstractAS4Client<AS4ClientUserMessage>- Parameters:
sMessageID- The message ID to be used. Neithernullnor empty.aCallback- Optional callback for in-between states. May benull.- Returns:
- The HTTP entity to be sent. Never
null. - Throws:
org.apache.wss4j.common.ext.WSSecurityException- In case there is an issue with signing/encryptionjakarta.mail.MessagingException- in case something happens in MIME wrapping
-