EbxmlMessage

public class EbxmlMessage

A representation of an ebXML message. An ebXML message conforms to the ` SOAP 1.1 with Attachments Specification <http://www.w3.org/TR/2000/NOTE-SOAP-attachments-20001211>`_. This EbxmlMessage encapsulates a javax.xml.soap.SOAPMessage.

Author:cyng

Fields

CHARACTER_SET_ENCODING

public static final String CHARACTER_SET_ENCODING

Default value XML character set

SOAP_ACTION

public static final String SOAP_ACTION

SOAPAction in the SOAP message MIME header

SOAP_ACTION_VALUE

public static final String SOAP_ACTION_VALUE

SOAPAction value in the SOAP message MIME header

SOAP_PART_CONTENT_ID

public static final String SOAP_PART_CONTENT_ID

Default content id of soap part

WRITE_XML_DECLARATION

public static final boolean WRITE_XML_DECLARATION

Default value of writing XML declaration in front of message

mimeBoundary

public static final String mimeBoundary

MIME boundary generated

needPatch

public static boolean needPatch

Description of the Field

Constructors

EbxmlMessage

public EbxmlMessage()

Constructs an EbxmlMessage using the default JAXM MessageFactory implementation

Throws:
  • SOAPException – Description of the Exception

EbxmlMessage

public EbxmlMessage(MessageFactory messageFactory)

Constructs an EbxmlMessage using the provided javax.xml.soap.MessageFactory

Parameters:
  • messageFactoryMessageFactory for creating message.
Throws:
  • SOAPException – Description of the Exception

EbxmlMessage

public EbxmlMessage(File file)

construct an EbxmlMessage from File using the logic in MessageServer. The file must not contain any content header like Content-Type

Parameters:
  • file – the file contain the messsage.
Throws:
  • SOAPException – Description of the Exception
  • IOException – Description of the Exception

EbxmlMessage

public EbxmlMessage(InputStream inputStream)

constructs an EbxmlMessage from InputStream using the logic in MessageServer. The input stream must not contain any content headers like Content-type.

Parameters:
  • inputStream – Description of the Parameter
Throws:
  • SOAPException – Description of the Exception
  • IOException – Description of the Exception

EbxmlMessage

public EbxmlMessage(SOAPMessage soapMessage)

Constructs an EbxmlMessage using the given SOAPMessage

Parameters:
  • soapMessage
Throws:
  • SOAPException – Description of the Exception

EbxmlMessage

public EbxmlMessage(MimeHeaders headers, InputStream in)

Constructs a EbxmlMessage using the given InputStream and default JAXM MessageFactory implementation

Parameters:
  • headers – MIME headers to be included in the message.
  • in – Message content in form of InputStream.
Throws:
  • IOException – Description of the Exception
  • SOAPException – Description of the Exception

Methods

addAckRequested

public void addAckRequested(boolean signed)

Add acknowledgement request element to the message.

Parameters:
  • signed – The feature to be added to the AckRequested attribute
Throws:
  • SOAPException

addAcknowledgment

public void addAcknowledgment(String timestamp, EbxmlMessage refToMessage)

Add acknowledgement element to the message using given timestamp, refToMessageId.

Parameters:
  • timestamp – Timestamp string expressed in UTC format.
  • refToMessage – The feature to be added to the Acknowledgment attribute
Throws:
  • SOAPException – Description of the Exception

addAcknowledgment

public void addAcknowledgment(String timestamp, EbxmlMessage refToMessage, String fromPartyId)

Add acknowledgement element to the message using given timestamp, refToMessageId and fromPartyId.

Parameters:
  • timestamp – Timestamp string expressed in UTC format.
  • fromPartyId – Sender party ID.
  • refToMessage – The feature to be added to the Acknowledgment attribute
Throws:
  • SOAPException – Description of the Exception

addAcknowledgment

public void addAcknowledgment(String timestamp, EbxmlMessage refToMessage, String fromPartyId, String fromPartyIdType)

Add acknowledgement element to the message using given timestamp, refToMessageId, fromPartyId and fromPartyIdType.

Parameters:
  • timestamp – Timestamp string expressed in UTC format.
  • fromPartyId – Sender party ID.
  • fromPartyIdType – Sender party ID type.
  • refToMessage – The feature to be added to the Acknowledgment attribute
Throws:
  • SOAPException – Description of the Exception

addErrorList

public void addErrorList(String errorCode, String severity, String description)

Add an error list to the message using given error code, severity and description.

Parameters:
  • errorCode – [ebMSS 4.2.3.4]
  • severity – Valid values are “Error” and “Warning”.
  • description – Description of the error.
Throws:
  • SOAPException – Description of the Exception

addErrorList

public void addErrorList(String errorCode, String severity, String description, String location)

Add an error list to the message using given error code, severity and description.

Parameters:
  • errorCode – [ebMSS 4.2.3.4]
  • severity – Valid values are “Error” and “Warning”.
  • description – Description of the error.
  • location – Location of the message containing the error.
Throws:
  • SOAPException

addMessageHeader

public MessageHeader addMessageHeader(String fromPartyId, String toPartyId, String cpaId, String conversationId, String service, String action, String messageId, String timestamp)

Adds a MessageHeader to this EbxmlMessage with the given mandatory fields

Parameters:
  • fromPartyId – Party ID of the sender [ebMSS 3.1.1.1]
  • toPartyId – Party ID of the receiver [ebMSS 3.1.1.1]
  • cpaId – CPA Id [ebMSS 3.1.2]
  • conversationId – ID of the conversation in which this message is involved [ebMSS 3.1.3]
  • service – Service name [ebMSS 3.1.4]
  • action – Action name [ebMSS 3.1.5]
  • messageId – Unique identifier of the message [ebMSS 3.1.6.1]
  • timestamp – Date/time of the message header creation expressed as UTC [ebMSS 3.1.6.2]
Throws:
  • SOAPException – Description of the Exception
Returns:

the newly added MessageHeader

addMessageHeader

public MessageHeader addMessageHeader(String fromPartyId, String fromPartyIdType, String toPartyId, String toPartyIdType, String cpaId, String conversationId, String service, String action, String messageId, String timestamp)

Adds a MessageHeader to this EbxmlMessage with the given mandatory fields

Parameters:
  • fromPartyId – Party ID of the sender [ebMSS 3.1.1.1]
  • fromPartyIdType – PartyID type of the sender [ebMSS 3.1.1.1]
  • toPartyId – Party ID of the receiver [ebMSS 3.1.1.1]
  • toPartyIdType – PartyID type of the receiver [ebMSS 3.1.1.1]
  • cpaId – CPA Id [ebMSS 3.1.2]
  • conversationId – ID of the conversation in which this message is involved [ebMSS 3.1.3]
  • service – Service name [ebMSS 3.1.4]
  • action – Action name [ebMSS 3.1.5]
  • messageId – Unique identifier of the message [ebMSS 3.1.6.1]
  • timestamp – Date/time of the message header creation expressed as UTC [ebMSS 3.1.6.2]
Throws:
  • SOAPException – Description of the Exception
Returns:

the newly added MessageHeader

addMessageHeader

public MessageHeader addMessageHeader()

Adds a default MessageHeader to this EbxmlMessage.

Throws:
  • SOAPException
Returns:

the newly added MessageHeader

addMessageOrder

public void addMessageOrder(int status, int sequenceNumber)

Add a MessageOrder element to the header.

Parameters:
  • status – Status of the sequence number. It should have the value of either MessageOrder.STATUS_RESET or MessageOrder.STATUS_CONTINUE.
  • sequenceNumber – Sequence number to be assigned to this message.
Throws:
  • SOAPException – Description of the Exception

addPayloadContainer

public PayloadContainer addPayloadContainer(DataHandler dataHandler, String contentId, String description)

Add an ebXML message payload container.

Parameters:
  • dataHandler – the DataHandler that generates the payload content.
  • contentId – the contentId of this payload attachment. The contentId must be unique among all payload attachment.
  • description – the description of this payload.
Throws:
  • SOAPException
Returns:

the PayloadContainer object that is created and added.

addStatusRequest

public void addStatusRequest(String refToMessageId)

Add a status request element to the message.

Parameters:
  • refToMessageId – Identifier of the message it is referring to.
Throws:
  • SOAPException

addStatusResponse

public void addStatusResponse(String refToMessageId, String messageStatus)

Add a status response element to the message.

Parameters:
  • refToMessageId – Identifier of the message it is referring to.
  • messageStatus – Status string to be added in the response element.
Throws:
  • SOAPException

addStatusResponse

public void addStatusResponse(String refToMessageId, String messageStatus, String timestamp)

Add a status response element to the message.

Parameters:
  • refToMessageId – Identifier of the message it is referring to.
  • messageStatus – Status string to be added in the response element.
  • timestamp – Timestamp of the status response expressed in UTC format.
Throws:
  • SOAPException

addSyncReply

public void addSyncReply()

Add a SyncReply element to the message.

Throws:
  • SOAPException

getAckRequested

public AckRequested getAckRequested()

Get acknowledgement request element.

Returns:AckRequested object representing the element.

getAcknowledgment

public Acknowledgment getAcknowledgment()

Get acknowledgement element.

Returns:Acknowledgement object representing the element.

getAction

public String getAction()

Gets action name

Returns:Action name

getBytes

public byte[] getBytes()
Returns:Returns the bytestream.

getConversationId

public String getConversationId()

Gets conversationId

Returns:Conversation ID

getCpaId

public String getCpaId()

Gets cpaId

Returns:CPA ID

getDatasource

public DataSource getDatasource()
Returns:Returns the datasource.

getDuplicateElimination

public boolean getDuplicateElimination()

Gets the flag stating if duplicate elimination is enabled or not.

Returns:true if duplicate elimination is required; false otherwise.

getErrorList

public ErrorList getErrorList()

Get the error list in the message.

Returns:ErrorList object containing error list in the message. Returns null if it does not exist.

getFileName

public String getFileName()

Gets the fileName attribute of the EbxmlMessage object. This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

Returns:The fileName value

getFromPartyIds

public Iterator getFromPartyIds()

Gets the list of from party IDs. There can be multiple party IDs [ebMSS 3.1.1].

Returns:Iterator pointing to a list of party IDs.

getHeaderContainer

public HeaderContainer getHeaderContainer()
Returns:Returns the headerContainer.

getManifest

public Manifest getManifest()

Gets the Manifest element in this ebXML message

Returns:Manifest element

getMessageFromDataSource

public static Object getMessageFromDataSource(DataSource dataSource, boolean withAttachments)

getMessageHeader

public MessageHeader getMessageHeader()

Get the message header of this ebXML message.

Returns:MessageHeader of this ebXML message.

getMessageId

public String getMessageId()

Gets messageId

Returns:Unique message identifier

getMessageOrder

public MessageOrder getMessageOrder()

Get the message order element in the message.

Returns:MessageOrder object if it exists in the ebXML message; null otherwise.

getMimeHeaders

public Map getMimeHeaders()

Gets the MIME headers of this ebXML message

Throws:
  • IOException – Description of the Exception
  • SOAPException – Description of the Exception
Returns:

the MIME headers of this ebXML message

getMimeHeaders

public Map getMimeHeaders(String soapEncoding, String payloadEncoding)

Gets the MIME headers of this ebXML message

Parameters:
  • soapEncoding – content transfer encoding to be applied to SOAP part when computing length
  • payloadEncoding – content transfer encoding to be applied to payload when computing length
Throws:
  • IOException – Description of the Exception
  • SOAPException – Description of the Exception
Returns:

the MIME headers of this ebXML message

getPayloadContainer

public PayloadContainer getPayloadContainer(String contentId)

Gets the payload that is identified by the given content ID.

Parameters:
  • contentId – Content ID of the payload to be retrieved.
Returns:

PayloadContainer of the given content ID or null if no such PayloadContainer exists

getPayloadContainers

public Iterator getPayloadContainers()

Gets all PayloadContainers’ attached in this EbxmlMessage object.

Returns:An iterator point to a list of payload containers.

getPayloadCount

public int getPayloadCount()

Gets the number of payloads in this ebXML message

Returns:the number of payloads

getPayloadInError

public String getPayloadInError()

Checks whether the number of payloads in the SOAP message matches with the Manifest element in the header or not, and return the Content-ID of the inconsistent payload.

Returns:content-id of the inconsistent payload; null if all payloads are consistent.

getPersistenceHandler

public Object getPersistenceHandler()

get the persistence handler if it is stored. This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

Returns:the persistence handler

getPersistenceName

public String getPersistenceName()

get the Persistence name if it is stored. This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

Returns:the persitence name

getSOAPMessage

public SOAPMessage getSOAPMessage()

Gets the SOAPMessage encapsulated in this EbxmlMessage.

Returns:SOAPMessage representing this EbxmlMessage

getService

public String getService()

Gets service name

Returns:Service name.

getServiceType

public String getServiceType()

Gets service type

Returns:Service type.

getSignatures

public Iterator getSignatures()

Get the digital signatures in the message.

Returns:Iterator of Signature objects in the message.

getSoapEnvelopeBytes

byte[] getSoapEnvelopeBytes()

Get the soap envelope in bytes. This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

getSoapEnvelopeBytesFromStream

public static byte[] getSoapEnvelopeBytesFromStream(InputStream stream)

parse the message from InputStream and get the byte array of SOAP Envelope

Parameters:
  • stream – the InputStream contains the message
Throws:
  • MessageServerException – throw if there is error on parsing
Returns:

the byte array of the Soap Envelope

getStatusRequest

public StatusRequest getStatusRequest()

Get the status request element in the message.

Returns:Content of the status request element stored in StatusRequest object.

getStatusResponse

public StatusResponse getStatusResponse()

Get the status response element in the message.

Returns:Content of the status response element stored in StatusResponse object.

getSyncReply

public boolean getSyncReply()

Gets the flag stating if sync reply is enabled or not.

Returns:true if sync reply is enabled; false otherwise.

getTimeToLive

public String getTimeToLive()

Gets TimeToLive of the message

Returns:TimeToLive expressed in UTC format.

getTimestamp

public String getTimestamp()

Gets timestamp

Returns:Timestamp of the message expressed in UTC format.

getToPartyIds

public Iterator getToPartyIds()

Gets the list of to party IDs. There can be multiple party IDs [ebMSS 3.1.1].

Returns:Iterator pointing to a list of party IDs.

saveChanges

public void saveChanges()

Updates the encapsulated SOAPMessage with all changes that have been made to it.

Throws:
  • SOAPException

See also: javax.xml.soap.SOAPMessage.saveChanges()

saveRequired

public boolean saveRequired()

Indicates whether the encapsulated SOAPMessage need to be updated by calling saveChanges on it.

Returns:true if it is required to call saveChanges on the message; false otherwise.

See also: javax.xml.soap.SOAPMessage.saveRequired()

setBytes

public void setBytes(byte[] bytes)
Parameters:
  • bytes – The bytestream to set.

setFileName

public void setFileName(String filename)

Sets the fileName attribute of the EbxmlMessage object. This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

Parameters:
  • filename – The new fileName value

setPayloadContainers

public ArrayList setPayloadContainers(ArrayList payloads)

Sets the PayloadContainer

Parameters:
  • payloads – The new payloadContainers value
Returns:

The old payload container as an array list

setPersistenceInfo

public void setPersistenceInfo(String persistenceName, Object handler, DataSource datasource)

set the persistence info to the message This function will only be used by the Hermes Server itself, and it is not expected for the client to call it.

Parameters:
  • persistenceName – the name on the persistence handler
  • handler – the persistence handler

setSoapEnvelopeBytes

public void setSoapEnvelopeBytes(byte[] soapEnvelopeBytes)

set the soap envelope in bytes. Those bytes will be used to verify This function will only be used by the Hermes Server itself, and it is not expected for the client to call it. the signature.

writeTo

public void writeTo(OutputStream out)

Writes the encapsulated SOAPMessage to the given output stream. The externalization format is as defined by the SOAP 1.1 with Attachments Specification.

Parameters:
  • outOutputStream to write the message to.
Throws:
  • IOException – Description of the Exception
  • SOAPException – Description of the Exception

writeTo

public void writeTo(OutputStream out, String soapEncoding, String payloadEncoding)

Writes the encapsulated SOAPMessage to the given output stream. The externalization format is as defined by the SOAP 1.1 with Attachments Specification.

Parameters:
  • outOutputStream to write the message to.
  • soapEncoding – Description of the Parameter
  • payloadEncoding – Description of the Parameter
Throws:
  • IOException – Description of the Exception
  • SOAPException – Description of the Exception