站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 jaxrpc API Documentation 英文版文档

MessagePart (JAXRPC API) - JBoss 4.0.1 sp1 jaxrpc API Documentation 英文版文档


org.apache.axis
Class MessagePart

java.lang.Object
  extended byjavax.xml.soap.SOAPPart
      extended byorg.apache.axis.message.SOAPPartImpl
          extended byorg.apache.axis.message.SOAPPartAxisImpl
              extended byorg.apache.axis.MessagePart
All Implemented Interfaces:
Document, Node, Part, Serializable

public class MessagePart
extends SOAPPartAxisImpl
implements Part

The SOAPPart provides access to the root part of the Message which contains the envelope.

SOAPPart implements Part, providing common MIME operations.

SOAPPart also allows access to its envelope, as a string, byte[], InputStream, or SOAPEnvelope. (This functionality used to be in Message, and has been moved here more or less verbatim pending further cleanup.)

Author:
Rob Jellinghaus (robj@unrealities.com), Doug Davis (dug@us.ibm.com), Glen Daniels (gdaniels@allaire.com), Heejune Ahn (cityboy@tmax.co.kr)
See Also:
Serialized Form

Field Summary
static int FORM_BODYINSTREAM
           
static int FORM_BYTES
           
static int FORM_FAULT
           
static int FORM_INPUTSTREAM
           
static int FORM_SOAPENVELOPE
           
static int FORM_STRING
           
protected  Document mDocument
          SOAPEnvelope is the Document Elements of this XML docuement
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
MessagePart(Message parent, Object initialContents, boolean isBodyStream)
          Create a new SOAPPart.
 
Method Summary
 void addMimeHeader(String header, String value)
          Add the specified MIME header, as per JAXM.
 Node adoptNode(Node node)
           
 Node appendChild(Node newChild)
           
 Node cloneNode(boolean deep)
           
 Attr createAttribute(String name)
           
 Attr createAttributeNS(String namespaceURI, String qualifiedName)
           
 CDATASection createCDATASection(String data)
           
 Comment createComment(String data)
           
 DocumentFragment createDocumentFragment()
           
 Element createElement(String tagName)
           
 Element createElementNS(String namespaceURI, String qualifiedName)
           
 EntityReference createEntityReference(String name)
           
 ProcessingInstruction createProcessingInstruction(String target, String data)
           
 Text createTextNode(String data)
           
 Iterator getAllMimeHeaders()
          Retrieves all the headers for this SOAPPart object as an iterator over the MimeHeader objects.
 byte[] getAsBytes()
          Get the contents of this Part (not the headers!), as a byte array.
 SOAPEnvelopeAxisImpl getAsSOAPEnvelope()
          Get the contents of this Part (not the MIME headers!), as a SOAPEnvelope.
 String getAsString()
          Get the contents of this Part (not the headers!), as a String.
 NamedNodeMap getAttributes()
           
 NodeList getChildNodes()
           
 Source getContent()
          Returns the content of the SOAPEnvelope as a JAXP Source object.
 String getContentId()
          Content ID.
 String getContentIdRef()
          Content ID.
 int getContentLength()
          Get the content length for this SOAPPart.
 String getContentLocation()
          Content location.
 String getContentType()
          Content type is always "text/xml" for SOAPParts.
 Object getCurrentMessage()
          Get the current message, in whatever form it happens to be right now.
 DocumentType getDoctype()
           
 Element getDocumentElement()
           
 Element getElementById(String elementId)
           
 NodeList getElementsByTagName(String tagname)
           
 NodeList getElementsByTagNameNS(String namespaceURI, String localName)
           
 String getEncoding()
           
 javax.xml.soap.SOAPEnvelope getEnvelope()
          Gets the SOAPEnvelope object associated with this SOAPPart object.
 Node getFirstChild()
           
 DOMImplementation getImplementation()
           
 Node getLastChild()
           
 String getLocalName()
           
 Iterator getMatchingMimeHeaders(String[] match)
          Get all headers that match.
 Message getMessage()
          Get the Message for this Part.
 String[] getMimeHeader(String name)
          Gets all the values of the MimeHeader object in this SOAPPart object that is identified by the given String.
 String getNamespaceURI()
           
 Node getNextSibling()
           
 String getNodeName()
          Node Implementation
 short getNodeType()
           
 String getNodeValue()
           
 Iterator getNonMatchingMimeHeaders(String[] match)
          Get all headers that do not match.
 Document getOwnerDocument()
           
 Node getParentNode()
           
 String getPrefix()
           
 Node getPreviousSibling()
           
 int getSize()
          Get the total size in bytes, including headers, of this Part.
 Document getSOAPDocument()
           
 boolean getStandalone()
           
 boolean getStrictErrorChecking()
           
 String getVersion()
           
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 Node importNode(Node importedNode, boolean deep)
           
 Node insertBefore(Node newChild, Node refChild)
           
 boolean isSupported(String feature, String version)
           
 void normalize()
           
 void removeAllMimeHeaders()
          Removes all the MimeHeader objects for this SOAPEnvelope object.
 Node removeChild(Node oldChild)
           
 void removeMimeHeader(String header)
          Removes all MIME headers that match the given name.
 Node replaceChild(Node newChild, Node oldChild)
           
 void setContent(Source source)
          Sets the content of the SOAPEnvelope object with the data from the given Source object.
 void setContentId(String newCid)
          Sets Content-Id of this part.
 void setContentLocation(String loc)
          Set content location.
 void setCurrentMessage(Object currMsg, int form)
          Set the current message
 void setEncoding(String s)
           
 void setMessage(Message msg)
          Set the Message for this Part.
 void setMimeHeader(String name, String value)
          Changes the first header entry that matches the given header name so that its value is the given value, adding a new header with the given name and value if no existing header is a match.
 void setNodeValue(String nodeValue)
           
 void setPrefix(String prefix)
           
 void setSOAPEnvelope(SOAPEnvelopeAxisImpl env)
          This set the SOAP Envelope for this part.
 void setStandalone(boolean flag)
           
 void setStrictErrorChecking(boolean flag)
           
 void setVersion(String s)
           
 void writeTo(Writer writer)
          Write the contents to the specified writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORM_STRING

public static final int FORM_STRING
See Also:
Constant Field Values

FORM_INPUTSTREAM

public static final int FORM_INPUTSTREAM
See Also:
Constant Field Values

FORM_SOAPENVELOPE

public static final int FORM_SOAPENVELOPE
See Also:
Constant Field Values

FORM_BYTES

public static final int FORM_BYTES
See Also:
Constant Field Values

FORM_BODYINSTREAM

public static final int FORM_BODYINSTREAM
See Also:
Constant Field Values

FORM_FAULT

public static final int FORM_FAULT
See Also:
Constant Field Values

mDocument

protected Document mDocument
SOAPEnvelope is the Document Elements of this XML docuement

Constructor Detail

MessagePart

public MessagePart(Message parent,
                   Object initialContents,
                   boolean isBodyStream)
Create a new SOAPPart.

Do not call this directly! Should only be called by Message.

Parameters:
parent - the parent Message
initialContents - the initial contens Object
isBodyStream - if the body is in a stream
Method Detail

getMessage

public Message getMessage()
Get the Message for this Part.

Returns:
the Message for this Part

setMessage

public void setMessage(Message msg)
Set the Message for this Part. Do not call this Directly. Called by Message.

Parameters:
msg - the Message for this part

getContentType

public String getContentType()
Content type is always "text/xml" for SOAPParts.

Specified by:
getContentType in interface Part
Returns:
the content type

getContentLength

public int getContentLength()
Get the content length for this SOAPPart. This will force buffering of the SOAPPart, but it will also cache the byte[] form of the SOAPPart.

Returns:
the content length in bytes

setSOAPEnvelope

public void setSOAPEnvelope(SOAPEnvelopeAxisImpl env)
This set the SOAP Envelope for this part.

Note: It breaks the chicken/egg created. I need a message to create an attachment... From the attachment I should be able to get a reference... I now want to edit elements in the envelope in order to place the attachment reference to it. How do I now update the SOAP envelope with what I've changed?

Parameters:
env - the SOAPEnvelope for this SOAPPart

getSize

public int getSize()
Get the total size in bytes, including headers, of this Part. TODO: For now, since we aren't actually doing MIME yet, this is the same as getContentLength(). Soon it will be different.

Returns:
the total size

writeTo

public void writeTo(Writer writer)
             throws IOException
Write the contents to the specified writer.

Parameters:
writer - the Writer to write to
Throws:
IOException

getCurrentMessage

public Object getCurrentMessage()
Get the current message, in whatever form it happens to be right now. Will return a String, byte[], InputStream, or SOAPEnvelope, depending on circumstances.

The method name is historical. TODO: rename this for clarity; should be more like getContents.

Returns:
the current content

setCurrentMessage

public void setCurrentMessage(Object currMsg,
                              int form)
Set the current message

Parameters:
currMsg -
form -

getAsBytes

public byte[] getAsBytes()
                  throws AxisFault
Get the contents of this Part (not the headers!), as a byte array. This will force buffering of the message.

Returns:
an array of bytes containing a byte representation of this Part
Throws:
AxisFault - if this Part can't be serialized to the byte array

getAsString

public String getAsString()
                   throws AxisFault
Get the contents of this Part (not the headers!), as a String. This will force buffering of the message.

Returns:
a String containing the content of this message
Throws:
AxisFault - if there is an error serializing this part

getAsSOAPEnvelope

public SOAPEnvelopeAxisImpl getAsSOAPEnvelope()
                                       throws AxisFault
Get the contents of this Part (not the MIME headers!), as a SOAPEnvelope. This will force a complete parse of the message.

Returns:
a SOAPEnvelope containing the message content
Throws:
AxisFault - if the envelope could not be constructed

addMimeHeader

public void addMimeHeader(String header,
                          String value)
Add the specified MIME header, as per JAXM.

Specified by:
addMimeHeader in interface Part
Overrides:
addMimeHeader in class SOAPPartImpl
Parameters:
header - the header to add
value - the value of that header

getContentLocation

public String getContentLocation()
Content location.

Specified by:
getContentLocation in interface Part
Overrides:
getContentLocation in class SOAPPartImpl
Returns:
the content location

setContentLocation

public void setContentLocation(String loc)
Set content location.

Specified by:
setContentLocation in interface Part
Overrides:
setContentLocation in class SOAPPartImpl
Parameters:
loc - the content location

setContentId

public void setContentId(String newCid)
Sets Content-Id of this part. already defined.

Specified by:
setContentId in interface Part
Overrides:
setContentId in class SOAPPartImpl
Parameters:
newCid - new Content-Id

getContentId

public String getContentId()
Content ID.

Specified by:
getContentId in interface Part
Overrides:
getContentId in class SOAPPartImpl
Returns:
the content ID

getContentIdRef

public String getContentIdRef()
Content ID.

Specified by:
getContentIdRef in interface Part
Returns:
the contentId reference value that should be used directly as an href in a SOAP element to reference this attachment. Not part of JAX-RPC, JAX-M, SAAJ, etc.

getMatchingMimeHeaders

public Iterator getMatchingMimeHeaders(String[] match)
Get all headers that match.

Specified by:
getMatchingMimeHeaders in interface Part
Overrides:
getMatchingMimeHeaders in class SOAPPartImpl
Parameters:
match - an array of Strings giving mime header names
Returns:
an Iterator over all values matching these headers

getNonMatchingMimeHeaders

public Iterator getNonMatchingMimeHeaders(String[] match)
Get all headers that do not match.

Specified by:
getNonMatchingMimeHeaders in interface Part
Overrides:
getNonMatchingMimeHeaders in class SOAPPartImpl
Parameters:
match - an array of Strings giving mime header names
Returns:
an Iterator over all values not matching these headers

setContent

public void setContent(Source source)
                throws javax.xml.soap.SOAPException
Sets the content of the SOAPEnvelope object with the data from the given Source object.

Overrides:
setContent in class SOAPPartImpl
Parameters:
source - javax.xml.transform.Source object with the data to be set
Throws:
javax.xml.soap.SOAPException - if there is a problem in setting the source
See Also:
getContent()

getContent

public Source getContent()
                  throws javax.xml.soap.SOAPException
Returns the content of the SOAPEnvelope as a JAXP Source object.

Overrides:
getContent in class SOAPPartImpl
Returns:
the content as a javax.xml.transform.Source object
Throws:
javax.xml.soap.SOAPException - if the implementation cannot convert the specified Source object
See Also:
setContent(javax.xml.transform.Source)

getAllMimeHeaders

public Iterator getAllMimeHeaders()
Retrieves all the headers for this SOAPPart object as an iterator over the MimeHeader objects.

Overrides:
getAllMimeHeaders in class SOAPPartImpl
Returns:
an Iterator object with all of the Mime headers for this SOAPPart object

setMimeHeader

public void setMimeHeader(String name,
                          String value)
Changes the first header entry that matches the given header name so that its value is the given value, adding a new header with the given name and value if no existing header is a match. If there is a match, this method clears all existing values for the first header that matches and sets the given value instead. If more than one header has the given name, this method removes all of the matching headers after the first one.

Note that RFC822 headers can contain only US-ASCII characters.

Overrides:
setMimeHeader in class SOAPPartImpl
Parameters:
name - a String giving the header name for which to search
value - a String giving the value to be set. This value will be substituted for the current value(s) of the first header that is a match if there is one. If there is no match, this value will be the value for a new MimeHeader object.
See Also:
getMimeHeader(java.lang.String)

getMimeHeader

public String[] getMimeHeader(String name)
Gets all the values of the MimeHeader object in this SOAPPart object that is identified by the given String.

Specified by:
getMimeHeader in interface Part
Overrides:
getMimeHeader in class SOAPPartImpl
Parameters:
name - the name of the header; example: "Content-Type"
Returns:
a String array giving all the values for the specified header
See Also:
setMimeHeader(java.lang.String, java.lang.String)

removeAllMimeHeaders

public void removeAllMimeHeaders()
Removes all the MimeHeader objects for this SOAPEnvelope object.

Overrides:
removeAllMimeHeaders in class SOAPPartImpl

removeMimeHeader

public void removeMimeHeader(String header)
Removes all MIME headers that match the given name.

Overrides:
removeMimeHeader in class SOAPPartImpl
Parameters:
header - a String giving the name of the MIME header(s) to be removed

getEnvelope

public javax.xml.soap.SOAPEnvelope getEnvelope()
                                        throws javax.xml.soap.SOAPException
Gets the SOAPEnvelope object associated with this SOAPPart object. Once the SOAP envelope is obtained, it can be used to get its contents.

Overrides:
getEnvelope in class SOAPPartImpl
Returns:
the SOAPEnvelope object for this SOAPPart object
Throws:
javax.xml.soap.SOAPException - if there is a SOAP error

getSOAPDocument

public Document getSOAPDocument()
Since:
SAAJ 1.2

getDoctype

public DocumentType getDoctype()
Specified by:
getDoctype in interface Document
Overrides:
getDoctype in class SOAPPartImpl
Returns:

getImplementation

public DOMImplementation getImplementation()
Specified by:
getImplementation in interface Document
Overrides:
getImplementation in class SOAPPartImpl
Returns:

getDocumentElement

public Element getDocumentElement()
Specified by:
getDocumentElement in interface Document
Overrides:
getDocumentElement in class SOAPPartImpl

createElement

public Element createElement(String tagName)
                      throws DOMException
Specified by:
createElement in interface Document
Overrides:
createElement in class SOAPPartImpl
Parameters:
tagName -
Returns:
Throws:
DOMException

createDocumentFragment

public DocumentFragment createDocumentFragment()
Specified by:
createDocumentFragment in interface Document
Overrides:
createDocumentFragment in class SOAPPartImpl

createTextNode

public Text createTextNode(String data)
Specified by:
createTextNode in interface Document
Overrides:
createTextNode in class SOAPPartImpl

createComment

public Comment createComment(String data)
Specified by:
createComment in interface Document
Overrides:
createComment in class SOAPPartImpl

createCDATASection

public CDATASection createCDATASection(String data)
                                throws DOMException
Specified by:
createCDATASection in interface Document
Overrides:
createCDATASection in class SOAPPartImpl
Throws:
DOMException

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
                                                  throws DOMException
Specified by:
createProcessingInstruction in interface Document
Overrides:
createProcessingInstruction in class SOAPPartImpl
Throws:
DOMException

createAttribute

public Attr createAttribute(String name)
                     throws DOMException
Specified by:
createAttribute in interface Document
Overrides:
createAttribute in class SOAPPartImpl
Throws:
DOMException

createEntityReference

public EntityReference createEntityReference(String name)
                                      throws DOMException
Specified by:
createEntityReference in interface Document
Overrides:
createEntityReference in class SOAPPartImpl
Throws:
DOMException

getElementsByTagName

public NodeList getElementsByTagName(String tagname)
Specified by:
getElementsByTagName in interface Document
Overrides:
getElementsByTagName in class SOAPPartImpl

importNode

public Node importNode(Node importedNode,
                       boolean deep)
                throws DOMException
Specified by:
importNode in interface Document
Overrides:
importNode in class SOAPPartImpl
Throws:
DOMException

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
                        throws DOMException
Specified by:
createElementNS in interface Document
Overrides:
createElementNS in class SOAPPartImpl
Throws:
DOMException

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
                       throws DOMException
Specified by:
createAttributeNS in interface Document
Overrides:
createAttributeNS in class SOAPPartImpl
Throws:
DOMException

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI,
                                       String localName)
Specified by:
getElementsByTagNameNS in interface Document
Overrides:
getElementsByTagNameNS in class SOAPPartImpl

getElementById

public Element getElementById(String elementId)
Specified by:
getElementById in interface Document
Overrides:
getElementById in class SOAPPartImpl

getEncoding

public String getEncoding()

setEncoding

public void setEncoding(String s)

getStandalone

public boolean getStandalone()

setStandalone

public void setStandalone(boolean flag)

getStrictErrorChecking

public boolean getStrictErrorChecking()

setStrictErrorChecking

public void setStrictErrorChecking(boolean flag)

getVersion

public String getVersion()

setVersion

public void setVersion(String s)

adoptNode

public Node adoptNode(Node node)
               throws DOMException
Throws:
DOMException

getNodeName

public String getNodeName()
Node Implementation

Specified by:
getNodeName in interface Node
Overrides:
getNodeName in class SOAPPartImpl

getNodeValue

public String getNodeValue()
                    throws DOMException
Specified by:
getNodeValue in interface Node
Overrides:
getNodeValue in class SOAPPartImpl
Throws:
DOMException

setNodeValue

public void setNodeValue(String nodeValue)
                  throws DOMException
Specified by:
setNodeValue in interface Node
Overrides:
setNodeValue in class SOAPPartImpl
Throws:
DOMException

getNodeType

public short getNodeType()
Specified by:
getNodeType in interface Node
Overrides:
getNodeType in class SOAPPartImpl

getParentNode

public Node getParentNode()
Specified by:
getParentNode in interface Node
Overrides:
getParentNode in class SOAPPartImpl

getChildNodes

public NodeList getChildNodes()
Specified by:
getChildNodes in interface Node
Overrides:
getChildNodes in class SOAPPartImpl

getFirstChild

public Node getFirstChild()
Specified by:
getFirstChild in interface Node
Overrides:
getFirstChild in class SOAPPartImpl

getLastChild

public Node getLastChild()
Specified by:
getLastChild in interface Node
Overrides:
getLastChild in class SOAPPartImpl

getPreviousSibling

public Node getPreviousSibling()
Specified by:
getPreviousSibling in interface Node
Overrides:
getPreviousSibling in class SOAPPartImpl

getNextSibling

public Node getNextSibling()
Specified by:
getNextSibling in interface Node
Overrides:
getNextSibling in class SOAPPartImpl

getAttributes

public NamedNodeMap getAttributes()
Specified by:
getAttributes in interface Node
Overrides:
getAttributes in class SOAPPartImpl

getOwnerDocument

public Document getOwnerDocument()
Specified by:
getOwnerDocument in interface Node
Overrides:
getOwnerDocument in class SOAPPartImpl

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Specified by:
insertBefore in interface Node
Overrides:
insertBefore in class SOAPPartImpl
Throws:
DOMException

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Specified by:
replaceChild in interface Node
Overrides:
replaceChild in class SOAPPartImpl
Throws:
DOMException

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Specified by:
removeChild in interface Node
Overrides:
removeChild in class SOAPPartImpl
Throws:
DOMException

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
Specified by:
appendChild in interface Node
Overrides:
appendChild in class SOAPPartImpl
Throws:
DOMException

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node
Overrides:
hasChildNodes in class SOAPPartImpl

cloneNode

public Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class SOAPPartImpl

normalize

public void normalize()
Specified by:
normalize in interface Node
Overrides:
normalize in class SOAPPartImpl

isSupported

public boolean isSupported(String feature,
                           String version)
Specified by:
isSupported in interface Node
Overrides:
isSupported in class SOAPPartImpl

getNamespaceURI

public String getNamespaceURI()
Specified by:
getNamespaceURI in interface Node
Overrides:
getNamespaceURI in class SOAPPartImpl

getPrefix

public String getPrefix()
Specified by:
getPrefix in interface Node
Overrides:
getPrefix in class SOAPPartImpl

setPrefix

public void setPrefix(String prefix)
               throws DOMException
Specified by:
setPrefix in interface Node
Overrides:
setPrefix in class SOAPPartImpl
Throws:
DOMException

getLocalName

public String getLocalName()
Specified by:
getLocalName in interface Node
Overrides:
getLocalName in class SOAPPartImpl

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node
Overrides:
hasAttributes in class SOAPPartImpl


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.