Package org.apache.axis2.jaxws.message
Interface XMLPart
- All Known Subinterfaces:
Message
- All Known Implementing Classes:
MessageImpl,XMLPartBase,XMLPartImpl
public interface XMLPart
XMLPart
The XML portion of a Message
The JAX-WS implementation (proxy, message receiver, etc.) interact with the
Message via Blocks. A Block is represented in the message as a root element tree
in either the header, body or fault detail section. The Blocks can be easily
decomposed into business objects (which are needed on the JAX-WS interfaces).
In addition, the JAX-WS handler model requires that the XMLPart be exposed as
an SAAJ SOAPEnvelope.
The XMLPart abstraction hides the details of the message transformations from
the JAX-WS implementation.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidappendHeaderBlock(String namespace, String localPart, Block block) appendHeaderBlock Append the block to the list of header blocks.voidclose()Used primarily to ensure the parser is forwarded to the end so it can be closed.org.apache.axiom.om.OMElementgetAsOMElement Get the xml part as a read/write OM...note this returns an OM SOAPEnvelope for all protocols...even RESTjakarta.xml.soap.SOAPEnvelopegetAsEnvelope Get the xml part as a read/write SOAPEnvelopegetBodyBlock(int index, Object context, BlockFactory blockFactory) getBodyBlock Get the body block at the specificed index.getBodyBlock(Object context, BlockFactory blockFactory) getBodyBlock Get the single Body Block.getBodyBlockQNames Calling this method will cache the OM.getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory) getHeaderBlock Get the firstheader block with the specified name.getHeaderBlocks(String namespace, String localPart, Object context, BlockFactory blockFactory, org.apache.axiom.soap.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.intGet indirection.intgetNumBodyBlocks Calling this method will cache the OM.intgetNumHeaderBlocksgetParent Get the Message object that this XMLPart is attached to, if it is attached to one at all.Get the protocol for this Message (soap11, soap12, etc.)jakarta.jws.soap.SOAPBinding.StylegetStyle()If the XMLPart represents a fault, an XMLFault is returned which describes the fault in a protocol agnostic mannerThe representation of the XMLPart may be in a number of different forms.getXMLStreamReader(boolean consume) Get the XMLStreamReader represented by this Message for the xml partbooleanisConsumed Return true if the part is consumed.booleanisFault()Determines whether the XMLPart represents a FaultvoidoutputTo(XMLStreamWriter writer, boolean consume) Write out the MessagevoidremoveBodyBlock(int index) removeBodyBlock Removes the indicated BodyBlockvoidremoveHeaderBlock(String namespace, String localPart) removeHeaderBlock Removes all header blocks with this namespace/localpartvoidsetBodyBlock(int index, Block block) setBodyBlock Set the block at the specified index Once set, the Message owns the block.voidsetBodyBlock(Block block) setBodyBlock Set this as block as the single block for the message.voidsetHeaderBlock(String namespace, String localPart, Block block) setHeaderBlock replaces the first existing header block with this new block.voidsetIndirection(int indirection) Set indirection.voidsetOperationElement(QName operationQName) Set the operation element qname.voidsetParent Set the Message object that will hold this XMLPartvoidsetStyle(jakarta.jws.soap.SOAPBinding.Style style) Set the Style.voidsetXMLFault(XMLFault xmlFault) Change the XMLPart so that it represents the fault described by XMLFaulttraceString(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 Details
-
getProtocol
Protocol getProtocol()Get the protocol for this Message (soap11, soap12, etc.)- Returns:
- Protocl
-
outputTo
void outputTo(XMLStreamWriter writer, boolean consume) throws XMLStreamException, jakarta.xml.ws.WebServiceException Write out the Message- Parameters:
writer- XMLStreamWriterconsume- true if this is the last request on the block.- Throws:
jakarta.xml.ws.WebServiceExceptionXMLStreamException
-
getXMLStreamReader
Get the XMLStreamReader represented by this Message for the xml part- Parameters:
consume- true if this is the last request on the Message- Returns:
- XMLStreamReader
- Throws:
jakarta.xml.ws.WebServiceExceptionXMLStreamException
-
getStyle
jakarta.jws.soap.SOAPBinding.Style getStyle()- Returns:
- the Style (document or rpc)
-
setStyle
void setStyle(jakarta.jws.soap.SOAPBinding.Style style) throws jakarta.xml.ws.WebServiceException 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.- Parameters:
style- Style- Throws:
jakarta.xml.ws.WebServiceException- See Also:
-
indirection
-
setIndirection
void setIndirection(int indirection) 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.- Parameters:
indirection- (0 or 1)
-
getIndirection
int getIndirection()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.- Returns:
- indirection (0 or 1)
-
getOperationElement
- Returns:
- the QName of the operation element if Style.rpc. Otherwise null
- Throws:
jakarta.xml.ws.WebServiceException
-
setOperationElement
Set the operation element qname. The operation qname is only used if Style.rpc- Parameters:
operationQName-- Throws:
jakarta.xml.ws.WebServiceException
-
isConsumed
boolean isConsumed()isConsumed Return true if the part is consumed. Once consumed, the information in the part is no longer available.- Returns:
- true if the block is consumed (a method was called with consume=true)
-
isFault
boolean isFault() throws jakarta.xml.ws.WebServiceExceptionDetermines whether the XMLPart represents a Fault- Returns:
- true if the message represents a fault
- Throws:
jakarta.xml.ws.WebServiceException
-
getXMLFault
If the XMLPart represents a fault, an XMLFault is returned which describes the fault in a protocol agnostic manner- Returns:
- the XMLFault object or null
- Throws:
jakarta.xml.ws.WebServiceException- See Also:
-
setXMLFault
Change the XMLPart so that it represents the fault described by XMLFault- Parameters:
xmlfault-- Throws:
jakarta.xml.ws.WebServiceException- See Also:
-
getParent
Message getParent()getParent Get the Message object that this XMLPart is attached to, if it is attached to one at all.- Returns:
-
setParent
setParent Set the Message object that will hold this XMLPart- Parameters:
m-
-
getAsSOAPEnvelope
jakarta.xml.soap.SOAPEnvelope getAsSOAPEnvelope() throws jakarta.xml.ws.WebServiceExceptiongetAsEnvelope Get the xml part as a read/write SOAPEnvelope- Returns:
- SOAPEnvelope
- Throws:
jakarta.xml.ws.WebServiceException
-
getAsOMElement
org.apache.axiom.om.OMElement getAsOMElement() throws jakarta.xml.ws.WebServiceExceptiongetAsOMElement Get the xml part as a read/write OM...note this returns an OM SOAPEnvelope for all protocols...even REST- Returns:
- OMElement
- Throws:
jakarta.xml.ws.WebServiceException
-
getNumBodyBlocks
int getNumBodyBlocks() throws jakarta.xml.ws.WebServiceExceptiongetNumBodyBlocks Calling this method will cache the OM. Avoid it in performant situations.- Returns:
- number of body blocks
- Throws:
jakarta.xml.ws.WebServiceException
-
getBodyBlockQNames
getBodyBlockQNames Calling this method will cache the OM. Avoid it in performant situations.- Returns:
- List of QNames
- Throws:
jakarta.xml.ws.WebServiceException
-
getBodyBlock
Block getBodyBlock(int index, Object context, BlockFactory blockFactory) throws jakarta.xml.ws.WebServiceException 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.- Parameters:
index-context-blockFactory-- Returns:
- Block or null
- Throws:
jakarta.xml.ws.WebServiceException- See Also:
-
getBodyBlock
Block getBodyBlock(Object context, BlockFactory blockFactory) throws jakarta.xml.ws.WebServiceException 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.- Parameters:
index-context-blockFactory-- Returns:
- Block or null
- Throws:
jakarta.xml.ws.WebServiceException
-
setBodyBlock
setBodyBlock Set the block at the specified index Once set, the Message owns the block. You must use the getBodyBlock method to access it.- Parameters:
index-block-- Throws:
jakarta.xml.ws.WebServiceException
-
setBodyBlock
setBodyBlock Set this as block as the single block for the message.- Parameters:
index-block-- Throws:
jakarta.xml.ws.WebServiceException
-
removeBodyBlock
void removeBodyBlock(int index) throws jakarta.xml.ws.WebServiceException removeBodyBlock Removes the indicated BodyBlock- Parameters:
index-- Throws:
jakarta.xml.ws.WebServiceException
-
getNumHeaderBlocks
int getNumHeaderBlocks() throws jakarta.xml.ws.WebServiceExceptiongetNumHeaderBlocks- Returns:
- number of header blocks
- Throws:
jakarta.xml.ws.WebServiceException
-
getHeaderBlock
Block getHeaderBlock(String namespace, String localPart, Object context, BlockFactory blockFactory) throws jakarta.xml.ws.WebServiceException 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.- Parameters:
namespace-localPart-context-blockFactory-- Returns:
- Block
- Throws:
jakarta.xml.ws.WebServiceException
-
getHeaderBlocks
List<Block> getHeaderBlocks(String namespace, String localPart, Object context, BlockFactory blockFactory, org.apache.axiom.soap.RolePlayer rolePlayer) throws jakarta.xml.ws.WebServiceException 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.- Parameters:
namespace- uri of headerlocalPart- local name of headercontext- context for blockFactoryblockFactory- kind of factory (i.e. JAXB)RolePlayer- determines acceptable roles (or null)- Returns:
- List
- Throws:
jakarta.xml.ws.WebServiceException
-
setHeaderBlock
void setHeaderBlock(String namespace, String localPart, Block block) throws jakarta.xml.ws.WebServiceException 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- Parameters:
namespace-localPart-block-- Throws:
jakarta.xml.ws.WebServiceException
-
appendHeaderBlock
void appendHeaderBlock(String namespace, String localPart, Block block) throws jakarta.xml.ws.WebServiceException appendHeaderBlock Append the block to the list of header blocks. The Message owns the block. You must use the getHeaderBlock method to access it.- Parameters:
namespace-localPart-block-- Throws:
jakarta.xml.ws.WebServiceException
-
getHeaderQNames
- Returns:
- QNames of headers
-
removeHeaderBlock
void removeHeaderBlock(String namespace, String localPart) throws jakarta.xml.ws.WebServiceException removeHeaderBlock Removes all header blocks with this namespace/localpart- Parameters:
namespace-localPart-- Throws:
jakarta.xml.ws.WebServiceException
-
traceString
Get a traceString...the trace string dumps the contents of the Block without forcing an underlying ill-performant transformation of the message.- Returns:
- String containing trace information
-
getXMLPartContentType
String getXMLPartContentType()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- Returns:
- String
-
close
void close()Used primarily to ensure the parser is forwarded to the end so it can be closed.
-