org.apache.axis

Class SOAPPart

public class SOAPPart extends SOAPPart 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)

Field Summary
static StringALLOW_FORM_OPTIMIZATION
property used to set SOAPEnvelope as default form
static intFORM_BODYINSTREAM
static intFORM_BYTES
static intFORM_FAULT
static intFORM_INPUTSTREAM
static intFORM_OPTIMIZED
static intFORM_SOAPENVELOPE
static intFORM_STRING
protected static Loglog
protected DocumentmDocument
SOAPEnvelope is the Document Elements of this XML docuement
Constructor Summary
SOAPPart(Message parent, Object initialContents, boolean isBodyStream)
Create a new SOAPPart.
Method Summary
voidaddMimeHeader(String header, String value)
Add the specified MIME header, as per JAXM.
NodeadoptNode(Node node)
NodeappendChild(Node newChild)
NodecloneNode(boolean deep)
shortcompareDocumentPosition(Node other)
AttrcreateAttribute(String name)
AttrcreateAttributeNS(String namespaceURI, String qualifiedName)
CDATASectioncreateCDATASection(String data)
CommentcreateComment(String data)
DocumentFragmentcreateDocumentFragment()
ElementcreateElement(String tagName)
ElementcreateElementNS(String namespaceURI, String qualifiedName)
EntityReferencecreateEntityReference(String name)
ProcessingInstructioncreateProcessingInstruction(String target, String data)
TextcreateTextNode(String data)
IteratorgetAllMimeHeaders()
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!)
SOAPEnvelopegetAsSOAPEnvelope()
Get the contents of this Part (not the MIME headers!)
StringgetAsString()
Get the contents of this Part (not the headers!)
NamedNodeMapgetAttributes()
StringgetBaseURI()
DOM Level 3 stubs
NodeListgetChildNodes()
SourcegetContent()
Returns the content of the SOAPEnvelope as a JAXP Source object.
StringgetContentId()
Content ID.
StringgetContentIdRef()
Content ID.
longgetContentLength()
Get the content length for this SOAPPart.
StringgetContentLocation()
Content location.
StringgetContentType()
Content type is always "text/xml" for SOAPParts.
intgetCurrentForm()
ObjectgetCurrentMessage()
Get the current message, in whatever form it happens to be right now.
DocumentTypegetDoctype()
ElementgetDocumentElement()
StringgetDocumentURI()
DOMConfigurationgetDomConfig()
ElementgetElementById(String elementId)
NodeListgetElementsByTagName(String tagname)
NodeListgetElementsByTagNameNS(String namespaceURI, String localName)
StringgetEncoding()
SOAPEnvelopegetEnvelope()
Gets the SOAPEnvelope object associated with this SOAPPart object.
ObjectgetFeature(String feature, String version)
NodegetFirstChild()
DOMImplementationgetImplementation()
StringgetInputEncoding()
NodegetLastChild()
StringgetLocalName()
IteratorgetMatchingMimeHeaders(String[] match)
Get all headers that match.
MessagegetMessage()
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.
StringgetNamespaceURI()
NodegetNextSibling()
StringgetNodeName()
Node Implementation
shortgetNodeType()
StringgetNodeValue()
IteratorgetNonMatchingMimeHeaders(String[] match)
Get all headers that do not match.
DocumentgetOwnerDocument()
NodegetParentNode()
StringgetPrefix()
NodegetPreviousSibling()
DocumentgetSOAPDocument()
booleangetStandalone()
booleangetStrictErrorChecking()
StringgetTextContent()
ObjectgetUserData(String key)
StringgetVersion()
StringgetXmlEncoding()
booleangetXmlStandalone()
StringgetXmlVersion()
booleanhasAttributes()
booleanhasChildNodes()
NodeimportNode(Node importedNode, boolean deep)
NodeinsertBefore(Node newChild, Node refChild)
booleanisBodyStream()
booleanisDefaultNamespace(String namespaceURI)
booleanisEqualNode(Node arg)
booleanisSameNode(Node other)
booleanisSupported(String feature, String version)
StringlookupNamespaceURI(String prefix)
StringlookupPrefix(String namespaceURI)
voidnormalize()
voidnormalizeDocument()
voidremoveAllMimeHeaders()
Removes all the MimeHeader objects for this SOAPEnvelope object.
NoderemoveChild(Node oldChild)
voidremoveMimeHeader(String header)
Removes all MIME headers that match the given name.
NoderenameNode(Node n, String namespaceURI, String qualifiedName)
NodereplaceChild(Node newChild, Node oldChild)
voidsaveChanges()
voidsetContent(Source source)
Sets the content of the SOAPEnvelope object with the data from the given Source object.
voidsetContentId(String newCid)
Sets Content-Id of this part. already defined.
voidsetContentLocation(String loc)
Set content location.
voidsetCurrentMessage(Object currMsg, int form)
Set the current message
voidsetDocumentURI(String documentURI)
voidsetEncoding(String s)
voidsetMessage(Message msg)
Set the Message for this Part.
voidsetMimeHeader(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.
voidsetNodeValue(String nodeValue)
voidsetPrefix(String prefix)
voidsetSOAPEnvelope(SOAPEnvelope env)
This set the SOAP Envelope for this part.
voidsetStandalone(boolean flag)
voidsetStrictErrorChecking(boolean flag)
voidsetTextContent(String textContent)
ObjectsetUserData(String key, Object data, UserDataHandler handler)
voidsetVersion(String s)
voidsetXmlStandalone(boolean xmlStandalone)
voidsetXmlVersion(String xmlVersion)
voidwriteTo(OutputStream os)
Write the contents to the specified stream.
voidwriteTo(Writer writer)
Write the contents to the specified writer.

Field Detail

ALLOW_FORM_OPTIMIZATION

public static final String ALLOW_FORM_OPTIMIZATION
property used to set SOAPEnvelope as default form

FORM_BODYINSTREAM

public static final int FORM_BODYINSTREAM

FORM_BYTES

public static final int FORM_BYTES

FORM_FAULT

public static final int FORM_FAULT

FORM_INPUTSTREAM

public static final int FORM_INPUTSTREAM

FORM_OPTIMIZED

public static final int FORM_OPTIMIZED

FORM_SOAPENVELOPE

public static final int FORM_SOAPENVELOPE

FORM_STRING

public static final int FORM_STRING

log

protected static Log log

mDocument

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

Constructor Detail

SOAPPart

public SOAPPart(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

addMimeHeader

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

Parameters: header the header to add value the value of that header

adoptNode

public Node adoptNode(Node node)

appendChild

public Node appendChild(Node newChild)

cloneNode

public Node cloneNode(boolean deep)

compareDocumentPosition

public short compareDocumentPosition(Node other)

createAttribute

public Attr createAttribute(String name)

createAttributeNS

public Attr createAttributeNS(String namespaceURI, String qualifiedName)

createCDATASection

public CDATASection createCDATASection(String data)

createComment

public Comment createComment(String data)

createDocumentFragment

public DocumentFragment createDocumentFragment()

createElement

public Element createElement(String tagName)

Parameters: tagName

Returns:

Throws: DOMException

createElementNS

public Element createElementNS(String namespaceURI, String qualifiedName)

createEntityReference

public EntityReference createEntityReference(String name)

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target, String data)

createTextNode

public Text createTextNode(String data)

getAllMimeHeaders

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

Returns: an Iterator object with all of the Mime headers for this SOAPPart object

getAsBytes

public byte[] getAsBytes()
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

getAsSOAPEnvelope

public SOAPEnvelope getAsSOAPEnvelope()
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

getAsString

public String getAsString()
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

getAttributes

public NamedNodeMap getAttributes()

getBaseURI

public String getBaseURI()
DOM Level 3 stubs

getChildNodes

public NodeList getChildNodes()

getContent

public Source getContent()
Returns the content of the SOAPEnvelope as a JAXP Source object.

Returns: the content as a javax.xml.transform.Source object

Throws: SOAPException if the implementation cannot convert the specified Source object

See Also: setContent(javax.xml.transform.Source)

getContentId

public String getContentId()
Content ID.

Returns: the content ID

getContentIdRef

public String getContentIdRef()
Content ID.

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.

getContentLength

public long 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

getContentLocation

public String getContentLocation()
Content location.

Returns: the content location

getContentType

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

Returns: the content type

getCurrentForm

public int getCurrentForm()

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

getDoctype

public DocumentType getDoctype()

Returns:

getDocumentElement

public Element getDocumentElement()

getDocumentURI

public String getDocumentURI()

getDomConfig

public DOMConfiguration getDomConfig()

getElementById

public Element getElementById(String elementId)

getElementsByTagName

public NodeList getElementsByTagName(String tagname)

getElementsByTagNameNS

public NodeList getElementsByTagNameNS(String namespaceURI, String localName)

getEncoding

public String getEncoding()

getEnvelope

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

Returns: the SOAPEnvelope object for this SOAPPart object

Throws: SOAPException if there is a SOAP error

getFeature

public Object getFeature(String feature, String version)

getFirstChild

public Node getFirstChild()

getImplementation

public DOMImplementation getImplementation()

Returns:

getInputEncoding

public String getInputEncoding()

getLastChild

public Node getLastChild()

getLocalName

public String getLocalName()

getMatchingMimeHeaders

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

Parameters: match an array of Strings giving mime header names

Returns: an Iterator over all values matching these headers

getMessage

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

Returns: the Message for this Part

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.

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)

getNamespaceURI

public String getNamespaceURI()

getNextSibling

public Node getNextSibling()

getNodeName

public String getNodeName()
Node Implementation

getNodeType

public short getNodeType()

getNodeValue

public String getNodeValue()

getNonMatchingMimeHeaders

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

Parameters: match an array of Strings giving mime header names

Returns: an Iterator over all values not matching these headers

getOwnerDocument

public Document getOwnerDocument()

getParentNode

public Node getParentNode()

getPrefix

public String getPrefix()

getPreviousSibling

public Node getPreviousSibling()

getSOAPDocument

public Document getSOAPDocument()

Since: SAAJ 1.2

getStandalone

public boolean getStandalone()

getStrictErrorChecking

public boolean getStrictErrorChecking()

getTextContent

public String getTextContent()

getUserData

public Object getUserData(String key)

getVersion

public String getVersion()

getXmlEncoding

public String getXmlEncoding()

getXmlStandalone

public boolean getXmlStandalone()

getXmlVersion

public String getXmlVersion()

hasAttributes

public boolean hasAttributes()

hasChildNodes

public boolean hasChildNodes()

importNode

public Node importNode(Node importedNode, boolean deep)

insertBefore

public Node insertBefore(Node newChild, Node refChild)

isBodyStream

public boolean isBodyStream()

isDefaultNamespace

public boolean isDefaultNamespace(String namespaceURI)

isEqualNode

public boolean isEqualNode(Node arg)

isSameNode

public boolean isSameNode(Node other)

isSupported

public boolean isSupported(String feature, String version)

lookupNamespaceURI

public String lookupNamespaceURI(String prefix)

lookupPrefix

public String lookupPrefix(String namespaceURI)

normalize

public void normalize()

normalizeDocument

public void normalizeDocument()

removeAllMimeHeaders

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

removeChild

public Node removeChild(Node oldChild)

removeMimeHeader

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

Parameters: header a String giving the name of the MIME header(s) to be removed

renameNode

public Node renameNode(Node n, String namespaceURI, String qualifiedName)

replaceChild

public Node replaceChild(Node newChild, Node oldChild)

saveChanges

public void saveChanges()

setContent

public void setContent(Source source)
Sets the content of the SOAPEnvelope object with the data from the given Source object.

Parameters: source javax.xml.transform.Source object with the data to be set

Throws: SOAPException if there is a problem in setting the source

See Also: getContent()

setContentId

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

Parameters: newCid new Content-Id

setContentLocation

public void setContentLocation(String loc)
Set content location.

Parameters: loc the content location

setCurrentMessage

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

Parameters: currMsg form

setDocumentURI

public void setDocumentURI(String documentURI)

setEncoding

public void setEncoding(String s)

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

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.

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. @ throws java.lang.IllegalArgumentException if there was a problem with the specified mime header name or value

See Also: getMimeHeader(java.lang.String)

setNodeValue

public void setNodeValue(String nodeValue)

setPrefix

public void setPrefix(String prefix)

setSOAPEnvelope

public void setSOAPEnvelope(SOAPEnvelope 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

setStandalone

public void setStandalone(boolean flag)

setStrictErrorChecking

public void setStrictErrorChecking(boolean flag)

setTextContent

public void setTextContent(String textContent)

setUserData

public Object setUserData(String key, Object data, UserDataHandler handler)

setVersion

public void setVersion(String s)

setXmlStandalone

public void setXmlStandalone(boolean xmlStandalone)

setXmlVersion

public void setXmlVersion(String xmlVersion)

writeTo

public void writeTo(OutputStream os)
Write the contents to the specified stream.

Parameters: os the java.io.OutputStream to write to

writeTo

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

Parameters: writer the Writer to write to

Copyright B) 2005 Apache Web Services Project. All Rights Reserved.