Class MessageImpl
- java.lang.Object
-
- org.apache.axis2.jaxws.message.impl.MessageImpl
-
public class MessageImpl extends Object implements Message
MessageImpl A Message is an XML part + Attachments. Most of the implementation delegates to the XMLPart implementation. NOTE: For XML/HTTP (REST), a SOAP 1.1. Envelope is built and the rest payload is placed in the body. This purposely mimics the Axis2 implementation.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDataHandler(DataHandler dh, String id)
Add Attachmentvoid
appendHeaderBlock(String namespace, String localPart, Block block)
appendHeaderBlock Append the block to the list of header blocks.void
close()
Used primarily to ensure the parser is forwarded to the end so it can be closed.OMElement
getAsOMElement()
getAsOMElement Get the xml part as a read/write OM...note this returns an OM SOAPEnvelope for all protocols...even RESTSOAPEnvelope
getAsSOAPEnvelope()
getAsEnvelope Get the xml part as a read/write SOAPEnvelopeSOAPMessage
getAsSOAPMessage()
getAsSOAPMessage Get the xml part as a read/write SOAPEnvelopeString
getAttachmentID(int index)
Get the indicated (non-soap part) attachment idString
getAttachmentID(String partName)
Get the indicated (non-soap part) attachment idList<String>
getAttachmentIDs()
Get the list of attachment content ids for the messageBlock
getBodyBlock(int index, Object context, BlockFactory blockFactory)
getBodyBlock Get the body block at the specificed index.Block
getBodyBlock(Object context, BlockFactory blockFactory)
getBodyBlock Get the single Body Block.List<QName>
getBodyBlockQNames()
getBodyBlockQNames Calling this method will cache the OM.DataHandler
getDataHandler(String cid)
Get the attachment identified by the contentIDBlock
getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory)
getHeaderBlock Get the firstheader block with the specified name.List<Block>
getHeaderBlocks(String namespace, String localPart, Object context, BlockFactory blockFactory, RolePlayer rolePlayer)
getHeaderBlock Get the header blocks with the specified name The BlockFactory and object context are passed in to help create the proper kind of block.Set<QName>
getHeaderQNames()
int
getIndirection()
Get indirection.MessageContext
getMessageContext()
Map
getMimeHeaders()
int
getNumBodyBlocks()
getNumBodyBlocks Calling this method will cache the OM.int
getNumHeaderBlocks()
getNumHeaderBlocksQName
getOperationElement()
Message
getParent()
getParent Get the Message object that this XMLPart is attached to, if it is attached to one at all.Protocol
getProtocol()
Get the protocol for this Message (soap11, soap12, etc.)SOAPBinding.Style
getStyle()
Object
getValue(Object context, BlockFactory blockFactory)
XMLFault
getXMLFault()
If the XMLPart represents a fault, an XMLFault is returned which describes the fault in a protocol agnostic mannerString
getXMLPartContentType()
The representation of the XMLPart may be in a number of different forms.XMLStreamReader
getXMLStreamReader(boolean consume)
Get the XMLStreamReader represented by this Message for the xml partboolean
isConsumed()
isConsumed Return true if the part is consumed.boolean
isDoingSWA()
boolean
isFault()
Determines whether the XMLPart represents a Faultboolean
isMTOMEnabled()
A message is MTOM enabled if the associated dispatch/client/impl/provider has a binding type that enables MTOM.boolean
isPostPivot()
void
outputTo(XMLStreamWriter writer, boolean consume)
Write out the Messagevoid
removeBodyBlock(int index)
removeBodyBlock Removes the indicated BodyBlockDataHandler
removeDataHandler(String cid)
Get the attachment and remove it from the Messagevoid
removeHeaderBlock(String namespace, String localPart)
removeHeaderBlock Removes all header blocks with this namespace/localpartvoid
setBodyBlock(int index, Block block)
setBodyBlock Set the block at the specified index Once set, the Message owns the block.void
setBodyBlock(Block block)
setBodyBlock Set this as block as the single block for the message.void
setDoingSWA(boolean value)
Indicate that an SWA DataHandler was added to the message.void
setHeaderBlock(String namespace, String localPart, Block block)
setHeaderBlock replaces the first existing header block with this new block.void
setIndirection(int indirection)
Set indirection.void
setMessageContext(MessageContext messageContext)
JAX-WS Message Context that owns the Messagevoid
setMimeHeaders(Map map)
Set the transport headersvoid
setMTOMEnabled(boolean b)
A message is MTOM enabled if the associated dispatch/client/impl/provider has a binding type that enables MTOM.void
setOperationElement(QName operationQName)
Set the operation element qname.void
setParent(Message msg)
setParent Set the Message object that will hold this XMLPartvoid
setPostPivot()
Indicate that this message is passed the pivot point.void
setStyle(SOAPBinding.Style style)
Set the Style.void
setXMLFault(XMLFault xmlFault)
Change the XMLPart so that it represents the fault described by XMLFaultString
traceString(String indent)
Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.
-
-
-
Method Detail
-
getAsSOAPMessage
public SOAPMessage getAsSOAPMessage() throws WebServiceException
Description copied from interface:Message
getAsSOAPMessage Get the xml part as a read/write SOAPEnvelope- Specified by:
getAsSOAPMessage
in interfaceMessage
- Returns:
- SOAPEnvelope
- Throws:
WebServiceException
-
getAttachmentID
public String getAttachmentID(int index)
Get the indicated (non-soap part) attachment id- Specified by:
getAttachmentID
in interfaceMessage
- Parameters:
index
-- Returns:
- CID or null if not present
-
getAttachmentID
public String getAttachmentID(String partName)
Description copied from interface:Message
Get the indicated (non-soap part) attachment id- Specified by:
getAttachmentID
in interfaceMessage
- Parameters:
partName
- (WS-I indicates that SWA attachments have a partName prefix)- Returns:
- CID or null if not present
-
getValue
public Object getValue(Object context, BlockFactory blockFactory) throws WebServiceException
- Specified by:
getValue
in interfaceMessage
- Throws:
WebServiceException
-
getAttachmentIDs
public List<String> getAttachmentIDs()
Description copied from interface:Message
Get the list of attachment content ids for the message- Specified by:
getAttachmentIDs
in interfaceMessage
- Returns:
- List
-
getDataHandler
public DataHandler getDataHandler(String cid)
Description copied from interface:Message
Get the attachment identified by the contentID- Specified by:
getDataHandler
in interfaceMessage
- Returns:
-
removeDataHandler
public DataHandler removeDataHandler(String cid)
Description copied from interface:Message
Get the attachment and remove it from the Message- Specified by:
removeDataHandler
in interfaceMessage
-
getProtocol
public Protocol getProtocol()
Description copied from interface:Message
Get the protocol for this Message (soap11, soap12, etc.)- Specified by:
getProtocol
in interfaceMessage
- Specified by:
getProtocol
in interfaceXMLPart
- Returns:
- Protocl
-
getAsOMElement
public OMElement getAsOMElement() throws WebServiceException
Description copied from interface:XMLPart
getAsOMElement Get the xml part as a read/write OM...note this returns an OM SOAPEnvelope for all protocols...even REST- Specified by:
getAsOMElement
in interfaceXMLPart
- Returns:
- OMElement
- Throws:
WebServiceException
-
getAsSOAPEnvelope
public SOAPEnvelope getAsSOAPEnvelope() throws WebServiceException
Description copied from interface:XMLPart
getAsEnvelope Get the xml part as a read/write SOAPEnvelope- Specified by:
getAsSOAPEnvelope
in interfaceXMLPart
- Returns:
- SOAPEnvelope
- Throws:
WebServiceException
-
getBodyBlock
public Block getBodyBlock(int index, Object context, BlockFactory blockFactory) throws WebServiceException
Description copied from interface:XMLPart
getBodyBlock Get the body block at the specificed index. The BlockFactory and object context are passed in to help create the proper kind of block. Calling this method will cache the OM. Avoid it in performant situations.- Specified by:
getBodyBlock
in interfaceXMLPart
- Returns:
- Block or null
- Throws:
WebServiceException
- See Also:
XMLPart.getBodyBlock(int,java.lang.Object,org.apache.axis2.jaxws.message.factory.BlockFactory)
-
getHeaderBlock
public Block getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory) throws WebServiceException
Description copied from interface:XMLPart
getHeaderBlock Get the firstheader block with the specified name. The BlockFactory and object context are passed in to help create the proper kind of block.- Specified by:
getHeaderBlock
in interfaceXMLPart
- Returns:
- Block
- Throws:
WebServiceException
-
getHeaderBlocks
public List<Block> getHeaderBlocks(String namespace, String localPart, Object context, BlockFactory blockFactory, RolePlayer rolePlayer) throws WebServiceException
Description copied from interface:XMLPart
getHeaderBlock Get the header blocks with the specified name The BlockFactory and object context are passed in to help create the proper kind of block.- Specified by:
getHeaderBlocks
in interfaceXMLPart
- Parameters:
namespace
- uri of headerlocalPart
- local name of headercontext
- context for blockFactoryblockFactory
- kind of factory (i.e. JAXB)- Returns:
- List
- Throws:
WebServiceException
-
getNumBodyBlocks
public int getNumBodyBlocks() throws WebServiceException
Description copied from interface:XMLPart
getNumBodyBlocks Calling this method will cache the OM. Avoid it in performant situations.- Specified by:
getNumBodyBlocks
in interfaceXMLPart
- Returns:
- number of body blocks
- Throws:
WebServiceException
-
getBodyBlockQNames
public List<QName> getBodyBlockQNames() throws WebServiceException
Description copied from interface:XMLPart
getBodyBlockQNames Calling this method will cache the OM. Avoid it in performant situations.- Specified by:
getBodyBlockQNames
in interfaceXMLPart
- Returns:
- List of QNames
- Throws:
WebServiceException
-
getNumHeaderBlocks
public int getNumHeaderBlocks() throws WebServiceException
Description copied from interface:XMLPart
getNumHeaderBlocks- Specified by:
getNumHeaderBlocks
in interfaceXMLPart
- Returns:
- number of header blocks
- Throws:
WebServiceException
-
getXMLStreamReader
public XMLStreamReader getXMLStreamReader(boolean consume) throws WebServiceException
Description copied from interface:XMLPart
Get the XMLStreamReader represented by this Message for the xml part- Specified by:
getXMLStreamReader
in interfaceXMLPart
- Parameters:
consume
- true if this is the last request on the Message- Returns:
- XMLStreamReader
- Throws:
WebServiceException
-
isConsumed
public boolean isConsumed()
Description copied from interface:XMLPart
isConsumed Return true if the part is consumed. Once consumed, the information in the part is no longer available.- Specified by:
isConsumed
in interfaceXMLPart
- Returns:
- true if the block is consumed (a method was called with consume=true)
-
outputTo
public void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, WebServiceException
Description copied from interface:XMLPart
Write out the Message- Specified by:
outputTo
in interfaceXMLPart
- Parameters:
writer
- XMLStreamWriterconsume
- true if this is the last request on the block.- Throws:
WebServiceException
XMLStreamException
-
removeBodyBlock
public void removeBodyBlock(int index) throws WebServiceException
Description copied from interface:XMLPart
removeBodyBlock Removes the indicated BodyBlock- Specified by:
removeBodyBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
removeHeaderBlock
public void removeHeaderBlock(String namespace, String localPart) throws WebServiceException
Description copied from interface:XMLPart
removeHeaderBlock Removes all header blocks with this namespace/localpart- Specified by:
removeHeaderBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
setBodyBlock
public void setBodyBlock(int index, Block block) throws WebServiceException
Description copied from interface:XMLPart
setBodyBlock Set the block at the specified index Once set, the Message owns the block. You must use the getBodyBlock method to access it.- Specified by:
setBodyBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
setHeaderBlock
public void setHeaderBlock(String namespace, String localPart, Block block) throws WebServiceException
Description copied from interface:XMLPart
setHeaderBlock replaces the first existing header block with this new block. If there is no existing header block, one is added to the end of the headers- Specified by:
setHeaderBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
appendHeaderBlock
public void appendHeaderBlock(String namespace, String localPart, Block block) throws WebServiceException
Description copied from interface:XMLPart
appendHeaderBlock Append the block to the list of header blocks. The Message owns the block. You must use the getHeaderBlock method to access it.- Specified by:
appendHeaderBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
traceString
public String traceString(String indent)
Description copied from interface:XMLPart
Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.- Specified by:
traceString
in interfaceXMLPart
- Returns:
- String containing trace information
-
addDataHandler
public void addDataHandler(DataHandler dh, String id)
Description copied from interface:Message
Add Attachment- Specified by:
addDataHandler
in interfaceMessage
- Parameters:
dh
- DataHandler (type of Attachment is inferred from dh.getContentType)id
- String which is the Attachment content id- See Also:
addAttachment(Attachment)
-
getParent
public Message getParent()
Description copied from interface:XMLPart
getParent Get the Message object that this XMLPart is attached to, if it is attached to one at all.
-
setParent
public void setParent(Message msg)
Description copied from interface:XMLPart
setParent Set the Message object that will hold this XMLPart
-
isMTOMEnabled
public boolean isMTOMEnabled()
Description copied from interface:Message
A message is MTOM enabled if the associated dispatch/client/impl/provider has a binding type that enables MTOM.- Specified by:
isMTOMEnabled
in interfaceMessage
- Returns:
- true if the binding for this message indicates mtom
-
setMTOMEnabled
public void setMTOMEnabled(boolean b)
Description copied from interface:Message
A message is MTOM enabled if the associated dispatch/client/impl/provider has a binding type that enables MTOM. Indicate whether this is an MTOM message- Specified by:
setMTOMEnabled
in interfaceMessage
- Parameters:
true
- if the binding for this message indicates mtom
-
getXMLFault
public XMLFault getXMLFault() throws WebServiceException
Description copied from interface:XMLPart
If the XMLPart represents a fault, an XMLFault is returned which describes the fault in a protocol agnostic manner- Specified by:
getXMLFault
in interfaceXMLPart
- Returns:
- the XMLFault object or null
- Throws:
WebServiceException
- See Also:
XMLFault
-
setXMLFault
public void setXMLFault(XMLFault xmlFault) throws WebServiceException
Description copied from interface:XMLPart
Change the XMLPart so that it represents the fault described by XMLFault- Specified by:
setXMLFault
in interfaceXMLPart
- Throws:
WebServiceException
- See Also:
XMLFault
-
isFault
public boolean isFault() throws WebServiceException
Description copied from interface:XMLPart
Determines whether the XMLPart represents a Fault- Specified by:
isFault
in interfaceXMLPart
- Returns:
- true if the message represents a fault
- Throws:
WebServiceException
-
getXMLPartContentType
public String getXMLPartContentType()
Description copied from interface:XMLPart
The representation of the XMLPart may be in a number of different forms. Currently the forms are UNKNOWN, OM, SOAPENVELOPE, and SPINE. This method returns a String containing one of these types. This method should only be used for trace and testing purposes. The consumer of a Message should not make any decisions based on the representation of the XMLPart- Specified by:
getXMLPartContentType
in interfaceXMLPart
- Returns:
- String
-
getStyle
public SOAPBinding.Style getStyle()
-
setStyle
public void setStyle(SOAPBinding.Style style) throws WebServiceException
Description copied from interface:XMLPart
Set the Style. If the style is DOCUMENT, the body blocks are located underneath the body element. If the style is set to RPC, then the body blocks are located underneath the rpc operation.- Specified by:
setStyle
in interfaceXMLPart
- Parameters:
style
- Style- Throws:
WebServiceException
- See Also:
indirection
-
getOperationElement
public QName getOperationElement() throws WebServiceException
- Specified by:
getOperationElement
in interfaceXMLPart
- Returns:
- the QName of the operation element if Style.rpc. Otherwise null
- Throws:
WebServiceException
-
setOperationElement
public void setOperationElement(QName operationQName) throws WebServiceException
Description copied from interface:XMLPart
Set the operation element qname. The operation qname is only used if Style.rpc- Specified by:
setOperationElement
in interfaceXMLPart
- Throws:
WebServiceException
-
getMimeHeaders
public Map getMimeHeaders()
- Specified by:
getMimeHeaders
in interfaceMessage
- Returns:
- get the transport headers map.
-
setMimeHeaders
public void setMimeHeaders(Map map)
Description copied from interface:Message
Set the transport headers- Specified by:
setMimeHeaders
in interfaceMessage
- Parameters:
map
- Map
-
getBodyBlock
public Block getBodyBlock(Object context, BlockFactory blockFactory) throws WebServiceException
Description copied from interface:XMLPart
getBodyBlock Get the single Body Block. The BlockFactory and object context are passed in to help create the proper kind of block. This method should only be invoked when it is known that there is zero or one block.- Specified by:
getBodyBlock
in interfaceXMLPart
- Returns:
- Block or null
- Throws:
WebServiceException
-
setBodyBlock
public void setBodyBlock(Block block) throws WebServiceException
Description copied from interface:XMLPart
setBodyBlock Set this as block as the single block for the message.- Specified by:
setBodyBlock
in interfaceXMLPart
- Throws:
WebServiceException
-
setPostPivot
public void setPostPivot()
Description copied from interface:Message
Indicate that this message is passed the pivot point. For example, this is set in the JAX-WS Dispatcher to indicate- Specified by:
setPostPivot
in interfaceMessage
-
isPostPivot
public boolean isPostPivot()
- Specified by:
isPostPivot
in interfaceMessage
- Returns:
- true if post pivot
-
getIndirection
public int getIndirection()
Description copied from interface:XMLPart
Get indirection. Used to force the code to look for blocks at a particular location. For DOCUMENT the default is 0 For RPC the default is 1 This method is used to override these settings for special cases.- Specified by:
getIndirection
in interfaceXMLPart
- Returns:
- indirection (0 or 1)
-
setIndirection
public void setIndirection(int indirection)
Description copied from interface:XMLPart
Set indirection. Used to force the code to look for blocks at a particular location. For DOCUMENT the default is 0 For RPC the default is 1 This method is used to override these settings for special cases.- Specified by:
setIndirection
in interfaceXMLPart
- Parameters:
indirection
- (0 or 1)
-
getMessageContext
public MessageContext getMessageContext()
- Specified by:
getMessageContext
in interfaceMessage
- Returns:
- JAX-WS MessageContext
-
setMessageContext
public void setMessageContext(MessageContext messageContext)
Description copied from interface:Message
JAX-WS Message Context that owns the Message- Specified by:
setMessageContext
in interfaceMessage
-
setDoingSWA
public void setDoingSWA(boolean value)
Description copied from interface:Message
Indicate that an SWA DataHandler was added to the message. This information will be used to trigger SWA serialization.- Specified by:
setDoingSWA
in interfaceMessage
-
isDoingSWA
public boolean isDoingSWA()
- Specified by:
isDoingSWA
in interfaceMessage
- Returns:
- true if SWA DataHandler is present
-
close
public void close()
Description copied from interface:XMLPart
Used primarily to ensure the parser is forwarded to the end so it can be closed.
-
getHeaderQNames
public Set<QName> getHeaderQNames()
- Specified by:
getHeaderQNames
in interfaceXMLPart
- Returns:
- QNames of headers
-
-