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.commons.traits.IGenericImplTrait<AS4ClientUserMessage>
AS4 client for
AS4UserMessage objects.- Author:
- Philip Helger, bayerlma
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AS4ClientUserMessageaddAttachment(WSS4JAttachment aAttachment) Adds a file as attachment to the message.final AS4ClientUserMessageaddAttachment(File aAttachment, com.helger.commons.mime.IMimeType aMimeType, EAS4CompressionMode eAS4CompressionMode) Adds a file as attachment to the message.final com.helger.commons.collection.impl.ICommonsList<WSS4JAttachment>buildMessage(String sMessageID, IAS4ClientBuildMessageCallback aCallback) Build the AS4 message to be sent.final com.helger.commons.collection.impl.ICommonsList<Ebms3Property>With properties optional info can be added for the receiving party.final Stringfinal Stringfinal Stringfinal Stringfinal Stringfinal Stringfinal Nodefinal IPModegetPMode()final Function<AS4ClientUserMessage,String> final Stringfinal Stringfinal Stringfinal Stringfinal Stringfinal booleanfinal booleanfinal 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 AS4ClientUserMessagesetAgreementRefValue(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 AS4ClientUserMessagesetConversationID(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 AS4ClientUserMessagesetForceMimeMessage(boolean bForceMimeMessage) Enable the enforcement of packaging the AS4 user message in a MIME message.final AS4ClientUserMessagesetFromPartyID(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 AS4ClientUserMessagesetFromPartyIDType(String sFromPartyIDType) The PartyID is an ID that identifies the C2 over which the message gets sent.final AS4ClientUserMessagesetFromRole(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 AS4ClientUserMessagesetPayload(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 AS4ClientUserMessagesetPModeID(String sPModeID) final AS4ClientUserMessagesetPModeIDFactory(Function<AS4ClientUserMessage, String> aPModeIDFactory) final AS4ClientUserMessagesetServiceType(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 AS4ClientUserMessagesetServiceValue(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 AS4ClientUserMessagesetToPartyID(String sToPartyID) * @see #setFromPartyID(String)final AS4ClientUserMessagesetToPartyIDType(String sToPartyIDType) * @see #setFromPartyIDType(String)final AS4ClientUserMessagefinal AS4ClientUserMessagesetUseLeg1(boolean bUseLeg1) DEFAULT is set totrue, if you want to use leg2 for the message setfalse.final voidsetUserMessageValuesFromPMode(IPMode aPMode, PModeLeg aEffectiveLeg) Methods inherited from class com.helger.phase4.client.AbstractAS4Client
createDefaultMessageIDFactory, createMessageID, cryptParams, ensureSendingDateTime, getAS4CryptoFactory, getAS4CryptoFactoryCrypt, getAS4CryptoFactorySign, getAS4ResourceHelper, getHttpPoster, getMessageIDFactory, getMessageType, getRefToMessageID, getSendingDateTime, getSendingDateTimeOrNow, getSoapVersion, hasRefToMessageID, httpRetrySettings, internalGetCryptoFactoryCrypt, internalGetCryptoFactorySign, sendMessageWithRetries, setAS4CryptoFactory, setAS4CryptoFactoryCrypt, setAS4CryptoFactorySign, setHttpPoster, setMessageID, setMessageIDFactory, setRefToMessageID, setSendingDateTime, setSendingDateTimeOrNow, 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.commons.traits.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
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.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
@Nonnull public final AS4ClientUserMessage addAttachment(@Nonnull File aAttachment, @Nonnull com.helger.commons.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
@Nonnull @ReturnsMutableObject public final com.helger.commons.collection.impl.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
-
setAgreementRefValue
@Nonnull public final 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
-
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
@Nonnull public final AS4ClientUserMessage setPModeIDFactory(@Nonnull Function<AS4ClientUserMessage, String> aPModeIDFactory) -
buildMessage
@Nonnull public AS4ClientBuiltMessage buildMessage(@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
-