Class AS4ClientUserMessage

All Implemented Interfaces:
com.helger.base.trait.IGenericImplTrait<AS4ClientUserMessage>

@NotThreadSafe public class AS4ClientUserMessage extends AbstractAS4Client<AS4ClientUserMessage>
AS4 client for AS4UserMessage objects.
Author:
Philip Helger, bayerlma
  • Field Details

    • DEFAULT_FORCE_MIME_MESSAGE

      public static final boolean DEFAULT_FORCE_MIME_MESSAGE
      See Also:
  • Constructor Details

    • AS4ClientUserMessage

      public AS4ClientUserMessage(@WillNotClose @NonNull AS4ResourceHelper aResHelper)
  • Method Details

    • getPayload

      public final @Nullable Node getPayload()
      Returns:
      The payload of the user message that will be placed in the SOAP body. May be null.
    • setPayload

      public final @NonNull AS4ClientUserMessage setPayload(@Nullable Node aPayload)
      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:
      true if a MIME message is always created, even if no attachments are present, false to use a simple SOAP message in case of absence of attachments. The default value is false
      Since:
      2.5.1
    • setForceMimeMessage

      public final @NonNull AS4ClientUserMessage setForceMimeMessage(boolean bForceMimeMessage)
      Enable the enforcement of packaging the AS4 user message in a MIME message.
      Parameters:
      bForceMimeMessage - true to enforce it, false to 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 be null.
      aMimeType - MIME type of the given file. May not be null.
      eAS4CompressionMode - which compression type should be used to compress the attachment. May be null.
      Returns:
      this for chaining
      Throws:
      IOException - if something goes wrong in the adding process or the compression
    • addAttachment

      public final @NonNull AS4ClientUserMessage addAttachment(@NonNull WSS4JAttachment aAttachment)
      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 be null.
      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

      public final @Nullable String getAction()
    • setAction

      public final @NonNull AS4ClientUserMessage setAction(@Nullable String sAction)
      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

      public final @Nullable String getServiceType()
    • setServiceType

      public final @NonNull AS4ClientUserMessage setServiceType(@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>
      Parameters:
      sServiceType - serviceType that should be set
      Returns:
      this for chaining
    • getServiceValue

      public final @Nullable String getServiceValue()
    • setServiceValue

      public final @NonNull AS4ClientUserMessage setServiceValue(@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.
      Parameters:
      sServiceValue - the service value that should be set
      Returns:
      this for chaining
    • getConversationID

      public final @Nullable String getConversationID()
    • setConversationID

      public final @NonNull AS4ClientUserMessage setConversationID(@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.
      Parameters:
      sConversationID - the conversationID that should be set
      Returns:
      this for chaining
    • getAgreementRefValue

      public final @Nullable String getAgreementRefValue()
      Returns:
      The value of the eb:AgreementRef element. May be null.
    • 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

      public final @Nullable String getAgreementTypeValue()
      Returns:
      The value of the eb:AgreementRef/@type attribute. May be null.
      Since:
      2.7.6
    • setAgreementTypeValue

      public final @NonNull AS4ClientUserMessage setAgreementTypeValue(@Nullable String sAgreementTypeValue)
      Set the value of the eb:AgreementRef/@type attribute.
      Parameters:
      sAgreementTypeValue - The value to be set. May be null.
      Returns:
      this for chaining
      Since:
      2.7.6
    • getFromRole

      public final @Nullable String getFromRole()
    • setFromRole

      public final @NonNull AS4ClientUserMessage setFromRole(@Nullable String sFromRole)
      The value of the Role element is a non-empty string, with a default value of http://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

      public final @Nullable String getFromPartyIDType()
    • setFromPartyIDType

      public final @NonNull AS4ClientUserMessage setFromPartyIDType(@Nullable String sFromPartyIDType)
      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

      public final @Nullable String getFromPartyID()
    • setFromPartyID

      public final @NonNull AS4ClientUserMessage setFromPartyID(@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.
      Parameters:
      sFromPartyID - the partyID that should be set
      Returns:
      this for chaining
    • getToRole

      public final @Nullable String getToRole()
    • setToRole

      public final @NonNull AS4ClientUserMessage setToRole(@Nullable String sToRole)
      Parameters:
      sToRole - the role that should be used
      Returns:
      this for chaining
      See Also:
    • getToPartyIDType

      public final @Nullable String getToPartyIDType()
    • setToPartyIDType

      public final @NonNull AS4ClientUserMessage setToPartyIDType(@Nullable String sToPartyIDType)
      * @see #setFromPartyIDType(String)
      Parameters:
      sToPartyIDType - the PartyID type that should be set
      Returns:
      this for chaining
    • getToPartyID

      public final @Nullable String getToPartyID()
    • setToPartyID

      public final @NonNull AS4ClientUserMessage setToPartyID(@Nullable String sToPartyID)
      * @see #setFromPartyID(String)
      Parameters:
      sToPartyID - the PartyID that should be set
      Returns:
      this for chaining
    • isUseLeg1

      public final boolean isUseLeg1()
    • setUseLeg1

      public final @NonNull AS4ClientUserMessage setUseLeg1(boolean bUseLeg1)
      DEFAULT is set to true, if you want to use leg2 for the message set false.
      Parameters:
      bUseLeg1 - true if leg1 should be used, false if leg2 should be used
      Returns:
      this for chaining
    • getPMode

      public final @Nullable IPMode getPMode()
    • setUserMessageValuesFromPMode

      public final void setUserMessageValuesFromPMode(@NonNull IPMode aPMode, @NonNull PModeLeg aEffectiveLeg)
    • setPMode

      public final void setPMode(@Nullable IPMode aPMode, boolean bSetValuesFromPMode)
      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 be null
      bSetValuesFromPMode - true to set all values in the client, that can be derived from the PMode, false to not do it.
    • getPModeIDFactory

      public final @NonNull Function<AS4ClientUserMessage,String> getPModeIDFactory()
    • setPModeID

      public final @NonNull AS4ClientUserMessage setPModeID(@Nullable String sPModeID)
    • 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: AbstractAS4Client
      Build 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:
      buildMessage in class AbstractAS4Client<AS4ClientUserMessage>
      Parameters:
      sMessageID - The message ID to be used. Neither null nor empty.
      aCallback - Optional callback for in-between states. May be null.
      Returns:
      The HTTP entity to be sent. Never null.
      Throws:
      org.apache.wss4j.common.ext.WSSecurityException - In case there is an issue with signing/encryption
      jakarta.mail.MessagingException - in case something happens in MIME wrapping