org.apache.axis

Class SOAPPart

Implemented Interfaces:
org.w3c.dom.Document, Part, java.io.Serializable

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.)

Authors:
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 String
ALLOW_FORM_OPTIMIZATION
property used to set SOAPEnvelope as default form
static int
FORM_BODYINSTREAM
static int
FORM_BYTES
static int
FORM_FAULT
static int
FORM_INPUTSTREAM
static int
FORM_OPTIMIZED
static int
FORM_SOAPENVELOPE
static int
FORM_STRING
protected static Log
log
protected Document
mDocument
SOAPEnvelope is the Document Elements of this XML docuement

Constructor Summary

SOAPPart(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)
short
compareDocumentPosition(Node foo)
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.
SOAPEnvelope
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()
String
getBaseURI()
NodeList
getChildNodes()
Source
getContent()
Returns the content of the SOAPEnvelope as a JAXP Source object.
String
getContentId()
Content ID.
String
getContentIdRef()
Content ID.
long
getContentLength()
Get the content length for this SOAPPart.
String
getContentLocation()
Content location.
String
getContentType()
Content type is always "text/xml" for SOAPParts.
int
getCurrentForm()
Object
getCurrentMessage()
Get the current message, in whatever form it happens to be right now.
DocumentType
getDoctype()
Element
getDocumentElement()
String
getDocumentURI()
DOMConfiguration
getDomConfig()
Element
getElementById(String elementId)
NodeList
getElementsByTagName(String tagname)
NodeList
getElementsByTagNameNS(String namespaceURI, String localName)
String
getEncoding()
SOAPEnvelope
getEnvelope()
Gets the SOAPEnvelope object associated with this SOAPPart object.
Object
getFeature(String foo1, String foo2)
Node
getFirstChild()
DOMImplementation
getImplementation()
String
getInputEncoding()
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()
Document
getSOAPDocument()
boolean
getStandalone()
boolean
getStrictErrorChecking()
String
getTextContent()
Object
getUserData(String foo)
String
getVersion()
String
getXmlEncoding()
boolean
getXmlStandalone()
String
getXmlVersion()
boolean
hasAttributes()
boolean
hasChildNodes()
Node
importNode(Node importedNode, boolean deep)
Node
insertBefore(Node newChild, Node refChild)
boolean
isBodyStream()
boolean
isDefaultNamespace(String foo)
boolean
isEqualNode(Node foo)
boolean
isSameNode(Node foo)
boolean
isSupported(String feature, String version)
String
lookupNamespaceURI(String foo)
String
lookupPrefix(String foo)
void
normalize()
void
normalizeDocument()
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
renameNode(Node foo1, String foo2, String foo3)
Node
replaceChild(Node newChild, Node oldChild)
void
saveChanges()
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
setDocumentURI(String foo)
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(SOAPEnvelope env)
This set the SOAP Envelope for this part.
void
setStandalone(boolean flag)
void
setStrictErrorChecking(boolean flag)
void
setTextContent(String foo)
Object
setUserData(String foo1, Object foo2, UserDataHandler foo3)
void
setVersion(String s)
void
setXmlStandalone(boolean foo)
void
setXmlVersion(String foo)
void
writeTo(Writer writer)
Write the contents to the specified writer.
void
writeTo(java.io.OutputStream os)
Write the contents to the specified stream.

Methods inherited from class javax.xml.soap.SOAPPart

addMimeHeader, getAllMimeHeaders, getContent, getContentId, getContentLocation, getEnvelope, getMatchingMimeHeaders, getMimeHeader, getNonMatchingMimeHeaders, removeAllMimeHeaders, removeMimeHeader, setContent, setContentId, setContentLocation, setMimeHeader

Field Details

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
Field Value:
5

FORM_BYTES

public static final int FORM_BYTES
Field Value:
4

FORM_FAULT

public static final int FORM_FAULT
Field Value:
6

FORM_INPUTSTREAM

public static final int FORM_INPUTSTREAM
Field Value:
2

FORM_OPTIMIZED

public static final int FORM_OPTIMIZED
Field Value:
7

FORM_SOAPENVELOPE

public static final int FORM_SOAPENVELOPE
Field Value:
3

FORM_STRING

public static final int FORM_STRING
Field Value:
1

log

protected static Log log

mDocument

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

Constructor Details

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 Details

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 interface SOAPPart
Parameters:
header - the header to add
value - the value of that header

adoptNode

public Node adoptNode(Node node)
            throws DOMException

appendChild

public Node appendChild(Node newChild)
            throws DOMException

cloneNode

public Node cloneNode(boolean deep)

compareDocumentPosition

public short compareDocumentPosition(Node foo)

createAttribute

public Attr createAttribute(String name)
            throws DOMException

createAttributeNS

public Attr createAttributeNS(String namespaceURI,
                              String qualifiedName)
            throws DOMException

createCDATASection

public CDATASection createCDATASection(String data)
            throws DOMException

createComment

public Comment createComment(String data)

createDocumentFragment

public DocumentFragment createDocumentFragment()

createElement

public Element createElement(String tagName)
            throws DOMException
Parameters:
tagName -
Returns:

createElementNS

public Element createElementNS(String namespaceURI,
                               String qualifiedName)
            throws DOMException

createEntityReference

public EntityReference createEntityReference(String name)
            throws DOMException

createProcessingInstruction

public ProcessingInstruction createProcessingInstruction(String target,
                                                         String data)
            throws DOMException

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.
Overrides:
getAllMimeHeaders in interface SOAPPart
Returns:
an Iterator object with all of the Mime headers for this SOAPPart object

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

getAsSOAPEnvelope

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

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

getAttributes

public NamedNodeMap getAttributes()

getBaseURI

public String getBaseURI()

getChildNodes

public NodeList getChildNodes()

getContent

public Source getContent()
            throws SOAPException
Returns the content of the SOAPEnvelope as a JAXP Source object.
Overrides:
getContent in interface SOAPPart
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.
Specified by:
getContentId in interface Part
Overrides:
getContentId in interface SOAPPart
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.

getContentLength

public long getContentLength()
            throws AxisFault
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.
Specified by:
getContentLocation in interface Part
Overrides:
getContentLocation in interface SOAPPart
Returns:
the content location

getContentType

public String getContentType()
Content type is always "text/xml" for SOAPParts.
Specified by:
getContentType in interface Part
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()
            throws 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 interface SOAPPart
Returns:
the SOAPEnvelope object for this SOAPPart object
Throws:
SOAPException - if there is a SOAP error

getFeature

public Object getFeature(String foo1,
                         String foo2)

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.
Specified by:
getMatchingMimeHeaders in interface Part
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.
Specified by:
getMimeHeader in interface Part
Overrides:
getMimeHeader in interface SOAPPart
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()
            throws DOMException

getNonMatchingMimeHeaders

public Iterator getNonMatchingMimeHeaders(String[] match)
Get all headers that do not match.
Specified by:
getNonMatchingMimeHeaders in interface Part
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 foo)

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)
            throws DOMException

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
            throws DOMException

isBodyStream

public boolean isBodyStream()

isDefaultNamespace

public boolean isDefaultNamespace(String foo)

isEqualNode

public boolean isEqualNode(Node foo)

isSameNode

public boolean isSameNode(Node foo)

isSupported

public boolean isSupported(String feature,
                           String version)

lookupNamespaceURI

public String lookupNamespaceURI(String foo)

lookupPrefix

public String lookupPrefix(String foo)

normalize

public void normalize()

normalizeDocument

public void normalizeDocument()

removeAllMimeHeaders

public void removeAllMimeHeaders()
Removes all the MimeHeader objects for this SOAPEnvelope object.
Overrides:
removeAllMimeHeaders in interface SOAPPart

removeChild

public Node removeChild(Node oldChild)
            throws DOMException

removeMimeHeader

public void removeMimeHeader(String header)
Removes all MIME headers that match the given name.
Overrides:
removeMimeHeader in interface SOAPPart
Parameters:
header - a String giving the name of the MIME header(s) to be removed

renameNode

public Node renameNode(Node foo1,
                       String foo2,
                       String foo3)

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
            throws DOMException

saveChanges

public void saveChanges()
            throws AxisFault

setContent

public void setContent(Source source)
            throws SOAPException
Sets the content of the SOAPEnvelope object with the data from the given Source object.
Overrides:
setContent in interface SOAPPart
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.
Specified by:
setContentId in interface Part
Overrides:
setContentId in interface SOAPPart
Parameters:
newCid - new Content-Id

setContentLocation

public void setContentLocation(String loc)
Set content location.
Specified by:
setContentLocation in interface Part
Overrides:
setContentLocation in interface SOAPPart
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 foo)

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.

Overrides:
setMimeHeader in interface SOAPPart
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)

setNodeValue

public void setNodeValue(String nodeValue)
            throws DOMException

setPrefix

public void setPrefix(String prefix)
            throws DOMException

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 foo)

setUserData

public Object setUserData(String foo1,
                          Object foo2,
                          UserDataHandler foo3)

setVersion

public void setVersion(String s)

setXmlStandalone

public void setXmlStandalone(boolean foo)

setXmlVersion

public void setXmlVersion(String foo)

writeTo

public void writeTo(Writer writer)
            throws IOException
Write the contents to the specified writer.
Parameters:
writer - the Writer to write to

writeTo

public void writeTo(java.io.OutputStream os)
            throws IOException
Write the contents to the specified stream.
Parameters:
os - the java.io.OutputStream to write to

Copyright © 2005 Apache Web Services Project. All Rights Reserved.