Class AS4ClientUserMessage

All Implemented Interfaces:
com.helger.commons.traits.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

  • Method Details

    • getPayload

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

      @Nonnull public final 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

      @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:
      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

      @Nonnull public final 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

      @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 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

      @Nonnull public final 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

      @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

      @Nullable public final String getAction()
    • setAction

      @Nonnull public final 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

      @Nullable public final String getServiceType()
    • setServiceType

      @Nonnull public final 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

      @Nullable public final String getServiceValue()
    • setServiceValue

      @Nonnull public final 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

      @Nullable public final String getConversationID()
    • setConversationID

      @Nonnull public final 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

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

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

      @Nonnull public final 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

      @Nullable public final String getFromRole()
    • setFromRole

      @Nonnull public final 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

      @Nullable public final String getFromPartyIDType()
    • setFromPartyIDType

      @Nonnull public final 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

      @Nullable public final String getFromPartyID()
    • setFromPartyID

      @Nonnull public final 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

      @Nullable public final String getToRole()
    • setToRole

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

      @Nullable public final String getToPartyIDType()
    • setToPartyIDType

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

      @Nullable public final String getToPartyID()
    • setToPartyID

      @Nonnull public final 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

      @Nonnull public final 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

      @Nullable public final 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

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

      @Nonnull public final AS4ClientUserMessage setPModeID(@Nullable String sPModeID)
    • 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: 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