SOAPPart (Java Platform SE 6) (original) (raw)



javax.xml.soap

Class SOAPPart

java.lang.Object extended by javax.xml.soap.SOAPPart

All Implemented Interfaces:

Document, Node


public abstract class SOAPPart

extends Object

implements Document, Node

The container for the SOAP-specific portion of a SOAPMessage object. All messages are required to have a SOAP part, so when aSOAPMessage object is created, it will automatically have a SOAPPart object.

A SOAPPart object is a MIME part and has the MIME headers Content-Id, Content-Location, and Content-Type. Because the value of Content-Type must be "text/xml", a SOAPPart object automatically has a MIME header of Content-Type with its value set to "text/xml". The value must be "text/xml" because content in the SOAP part of a message must be in XML format. Content that is not of type "text/xml" must be in an AttachmentPart object rather than in theSOAPPart object.

When a message is sent, its SOAP part must have the MIME header Content-Type set to "text/xml". Or, from the other perspective, the SOAP part of any message that is received must have the MIME header Content-Type with a value of "text/xml".

A client can access the SOAPPart object of aSOAPMessage object by calling the method SOAPMessage.getSOAPPart. The following line of code, in which message is aSOAPMessage object, retrieves the SOAP part of a message.

SOAPPart soapPart = message.getSOAPPart();

A SOAPPart object contains a SOAPEnvelope object, which in turn contains a SOAPBody object and aSOAPHeader object. The SOAPPart method getEnvelope can be used to retrieve the SOAPEnvelope object.


Field Summary
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Constructor Summary
SOAPPart()
Method Summary
abstract void [addMimeHeader](../../../javax/xml/soap/SOAPPart.html#addMimeHeader%28java.lang.String, java.lang.String%29)(String name,String value) Creates a MimeHeader object with the specified name and value and adds it to this SOAPPart object.
abstract Iterator getAllMimeHeaders() Retrieves all the headers for this SOAPPart object as an iterator over the MimeHeader objects.
abstract Source getContent() Returns the content of the SOAPEnvelope as a JAXP Source object.
String getContentId() Retrieves the value of the MIME header whose name is "Content-Id".
String getContentLocation() Retrieves the value of the MIME header whose name is "Content-Location".
abstract SOAPEnvelope getEnvelope() Gets the SOAPEnvelope object associated with thisSOAPPart object.
abstract Iterator getMatchingMimeHeaders(String[] names) Retrieves all MimeHeader objects that match a name in the given array.
abstract String[] getMimeHeader(String name) Gets all the values of the MimeHeader object in this SOAPPart object that is identified by the given String.
abstract Iterator getNonMatchingMimeHeaders(String[] names) Retrieves all MimeHeader objects whose name does not match a name in the given array.
abstract void removeAllMimeHeaders() Removes all the MimeHeader objects for thisSOAPEnvelope object.
abstract void removeMimeHeader(String header) Removes all MIME headers that match the given name.
abstract void setContent(Source source) Sets the content of the SOAPEnvelope object with the data from the given Source object.
void setContentId(String contentId) Sets the value of the MIME header named "Content-Id" to the given String.
void setContentLocation(String contentLocation) Sets the value of the MIME header "Content-Location" to the given String.
abstract void [setMimeHeader](../../../javax/xml/soap/SOAPPart.html#setMimeHeader%28java.lang.String, java.lang.String%29)(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.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, [wait](../../../java/lang/Object.html#wait%28long, int%29)
Methods inherited from interface org.w3c.dom.Document
adoptNode, createAttribute, [createAttributeNS](../../../org/w3c/dom/Document.html#createAttributeNS%28java.lang.String, java.lang.String%29), createCDATASection, createComment, createDocumentFragment, createElement, [createElementNS](../../../org/w3c/dom/Document.html#createElementNS%28java.lang.String, java.lang.String%29), createEntityReference, [createProcessingInstruction](../../../org/w3c/dom/Document.html#createProcessingInstruction%28java.lang.String, java.lang.String%29), createTextNode, getDoctype, getDocumentElement, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, [getElementsByTagNameNS](../../../org/w3c/dom/Document.html#getElementsByTagNameNS%28java.lang.String, java.lang.String%29), getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, [importNode](../../../org/w3c/dom/Document.html#importNode%28org.w3c.dom.Node, boolean%29), normalizeDocument, [renameNode](../../../org/w3c/dom/Document.html#renameNode%28org.w3c.dom.Node, java.lang.String, java.lang.String%29), setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersion
Methods inherited from interface javax.xml.soap.Node
detachNode, getParentElement, getValue, recycleNode, setParentElement, setValue
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, [getFeature](../../../org/w3c/dom/Node.html#getFeature%28java.lang.String, java.lang.String%29), getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, [insertBefore](../../../org/w3c/dom/Node.html#insertBefore%28org.w3c.dom.Node, org.w3c.dom.Node%29), isDefaultNamespace, isEqualNode, isSameNode, [isSupported](../../../org/w3c/dom/Node.html#isSupported%28java.lang.String, java.lang.String%29), lookupNamespaceURI, lookupPrefix, normalize, removeChild, [replaceChild](../../../org/w3c/dom/Node.html#replaceChild%28org.w3c.dom.Node, org.w3c.dom.Node%29), setNodeValue, setPrefix, setTextContent, [setUserData](../../../org/w3c/dom/Node.html#setUserData%28java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler%29)
Constructor Detail

SOAPPart

public SOAPPart()

Method Detail

getEnvelope

public abstract SOAPEnvelope getEnvelope() throws SOAPException

Gets the SOAPEnvelope object associated with thisSOAPPart object. Once the SOAP envelope is obtained, it can be used to get its contents.

Returns:

the SOAPEnvelope object for thisSOAPPart object

Throws:

[SOAPException](../../../javax/xml/soap/SOAPException.html "class in javax.xml.soap") - if there is a SOAP error


getContentId

public String getContentId()

Retrieves the value of the MIME header whose name is "Content-Id".

Returns:

a String giving the value of the MIME header named "Content-Id"

See Also:

setContentId(java.lang.String)


getContentLocation

public String getContentLocation()

Retrieves the value of the MIME header whose name is "Content-Location".

Returns:

a String giving the value of the MIME header whose name is "Content-Location"

See Also:

setContentLocation(java.lang.String)


setContentId

public void setContentId(String contentId)

Sets the value of the MIME header named "Content-Id" to the given String.

Parameters:

contentId - a String giving the value of the MIME header "Content-Id"

Throws:

[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang") - if there is a problem in setting the content id

See Also:

getContentId()


setContentLocation

public void setContentLocation(String contentLocation)

Sets the value of the MIME header "Content-Location" to the given String.

Parameters:

contentLocation - a String giving the value of the MIME header "Content-Location"

Throws:

[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang") - if there is a problem in setting the content location.

See Also:

getContentLocation()


removeMimeHeader

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


removeAllMimeHeaders

public abstract void removeAllMimeHeaders()

Removes all the MimeHeader objects for thisSOAPEnvelope object.


getMimeHeader

public abstract 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)](../../../javax/xml/soap/SOAPPart.html#setMimeHeader%28java.lang.String, java.lang.String%29)


setMimeHeader

public abstract 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:

[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang") - if there was a problem with the specified mime header name or value

See Also:

getMimeHeader(java.lang.String)


addMimeHeader

public abstract void addMimeHeader(String name, String value)

Creates a MimeHeader object with the specified name and value and adds it to this SOAPPart object. If a MimeHeader with the specified name already exists, this method adds the specified value to the already existing value(s).

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

Parameters:

name - a String giving the header name

value - a String giving the value to be set or added

Throws:

[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang") - if there was a problem with the specified mime header name or value


getAllMimeHeaders

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


getMatchingMimeHeaders

public abstract Iterator getMatchingMimeHeaders(String[] names)

Retrieves all MimeHeader objects that match a name in the given array.

Parameters:

names - a String array with the name(s) of the MIME headers to be returned

Returns:

all of the MIME headers that match one of the names in the given array, returned as an Iterator object


getNonMatchingMimeHeaders

public abstract Iterator getNonMatchingMimeHeaders(String[] names)

Retrieves all MimeHeader objects whose name does not match a name in the given array.

Parameters:

names - a String array with the name(s) of the MIME headers not to be returned

Returns:

all of the MIME headers in this SOAPPart object except those that match one of the names in the given array. The nonmatching MIME headers are returned as anIterator object.


setContent

public abstract void setContent(Source source) throws SOAPException

Sets the content of the SOAPEnvelope object with the data from the given Source object. This Source must contain a valid SOAP document.

Parameters:

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

Throws:

[SOAPException](../../../javax/xml/soap/SOAPException.html "class in javax.xml.soap") - if there is a problem in setting the source

See Also:

getContent()


getContent

public abstract Source getContent() throws SOAPException

Returns the content of the SOAPEnvelope as a JAXP Source object.

Returns:

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

Throws:

[SOAPException](../../../javax/xml/soap/SOAPException.html "class in javax.xml.soap") - if the implementation cannot convert the specified Source object

See Also:

setContent(javax.xml.transform.Source)



Submit a bug or feature
For further API reference and developer documentation, see Java SE Developer Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.

Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Scripting on this page tracks web page traffic, but does not change the content in any way.