Class SOAPPart
SOAPMessage
object. All messages are required to have a SOAP part, so when a
SOAPMessage 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 the
SOAPPart 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 a
SOAPMessage object by
calling the method SOAPMessage.getSOAPPart. The
following line of code, in which message is a
SOAPMessage 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 a
SOAPHeader object.
The SOAPPart method getEnvelope can be used
to retrieve the SOAPEnvelope object.
- Since:
- 1.6
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddMimeHeader(String name, String value) Creates aMimeHeaderobject with the specified name and value and adds it to thisSOAPPartobject.abstract Iterator<MimeHeader>Retrieves all the headers for thisSOAPPartobject as an iterator over theMimeHeaderobjects.abstract SourceReturns the content of the SOAPEnvelope as a JAXPSourceobject.Retrieves the value of the MIME header whose name is "Content-Id".Retrieves the value of the MIME header whose name is "Content-Location".abstract SOAPEnvelopeGets theSOAPEnvelopeobject associated with thisSOAPPartobject.abstract Iterator<MimeHeader>getMatchingMimeHeaders(String[] names) Retrieves allMimeHeaderobjects that match a name in the given array.abstract String[]getMimeHeader(String name) Gets all the values of theMimeHeaderobject in thisSOAPPartobject that is identified by the givenString.abstract Iterator<MimeHeader>getNonMatchingMimeHeaders(String[] names) Retrieves allMimeHeaderobjects whose name does not match a name in the given array.abstract voidRemoves all theMimeHeaderobjects for thisSOAPEnvelopeobject.abstract voidremoveMimeHeader(String header) Removes all MIME headers that match the given name.abstract voidsetContent(Source source) Sets the content of theSOAPEnvelopeobject with the data from the givenSourceobject.voidsetContentId(String contentId) Sets the value of the MIME header named "Content-Id" to the givenString.voidsetContentLocation(String contentLocation) Sets the value of the MIME header "Content-Location" to the givenString.abstract 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.w3c.dom.Document
adoptNode, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, getDoctype, getDocumentElement, getDocumentURI, getDomConfig, getElementById, getElementsByTagName, getElementsByTagNameNS, getImplementation, getInputEncoding, getStrictErrorChecking, getXmlEncoding, getXmlStandalone, getXmlVersion, importNode, normalizeDocument, renameNode, setDocumentURI, setStrictErrorChecking, setXmlStandalone, setXmlVersionMethods inherited from interface jakarta.xml.soap.Node
detachNode, getParentElement, getValue, recycleNode, setParentElement, setValueMethods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Constructor Details
-
SOAPPart
public SOAPPart()
-
-
Method Details
-
getEnvelope
Gets theSOAPEnvelopeobject associated with thisSOAPPartobject. Once the SOAP envelope is obtained, it can be used to get its contents.- Returns:
- the
SOAPEnvelopeobject for thisSOAPPartobject - Throws:
SOAPException- if there is a SOAP error
-
getContentId
Retrieves the value of the MIME header whose name is "Content-Id".- Returns:
- a
Stringgiving the value of the MIME header named "Content-Id" - See Also:
-
getContentLocation
Retrieves the value of the MIME header whose name is "Content-Location".- Returns:
- a
Stringgiving the value of the MIME header whose name is "Content-Location" - See Also:
-
setContentId
Sets the value of the MIME header named "Content-Id" to the givenString.- Parameters:
contentId- aStringgiving the value of the MIME header "Content-Id"- Throws:
IllegalArgumentException- if there is a problem in setting the content id- See Also:
-
setContentLocation
Sets the value of the MIME header "Content-Location" to the givenString.- Parameters:
contentLocation- aStringgiving the value of the MIME header "Content-Location"- Throws:
IllegalArgumentException- if there is a problem in setting the content location.- See Also:
-
removeMimeHeader
Removes all MIME headers that match the given name.- Parameters:
header- aStringgiving the name of the MIME header(s) to be removed
-
removeAllMimeHeaders
public abstract void removeAllMimeHeaders()Removes all theMimeHeaderobjects for thisSOAPEnvelopeobject. -
getMimeHeader
Gets all the values of theMimeHeaderobject in thisSOAPPartobject that is identified by the givenString.- Parameters:
name- the name of the header; example: "Content-Type"- Returns:
- a
Stringarray giving all the values for the specified header - See Also:
-
setMimeHeader
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- aStringgiving the header name for which to searchvalue- aStringgiving 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 newMimeHeaderobject.- Throws:
IllegalArgumentException- if there was a problem with the specified mime header name or value- See Also:
-
addMimeHeader
Creates aMimeHeaderobject with the specified name and value and adds it to thisSOAPPartobject. If aMimeHeaderwith 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- aStringgiving the header namevalue- aStringgiving the value to be set or added- Throws:
IllegalArgumentException- if there was a problem with the specified mime header name or value
-
getAllMimeHeaders
Retrieves all the headers for thisSOAPPartobject as an iterator over theMimeHeaderobjects.- Returns:
- an
Iteratorobject with all of the Mime headers for thisSOAPPartobject
-
getMatchingMimeHeaders
Retrieves allMimeHeaderobjects that match a name in the given array.- Parameters:
names- aStringarray 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
Iteratorobject
-
getNonMatchingMimeHeaders
Retrieves allMimeHeaderobjects whose name does not match a name in the given array.- Parameters:
names- aStringarray with the name(s) of the MIME headers not to be returned- Returns:
- all of the MIME headers in this
SOAPPartobject except those that match one of the names in the given array. The nonmatching MIME headers are returned as anIteratorobject.
-
setContent
Sets the content of theSOAPEnvelopeobject with the data from the givenSourceobject. ThisSourcemust contain a valid SOAP document.- Parameters:
source- thejavax.xml.transform.Sourceobject with the data to be set- Throws:
SOAPException- if there is a problem in setting the source- See Also:
-
getContent
Returns the content of the SOAPEnvelope as a JAXPSourceobject.- Returns:
- the content as a
javax.xml.transform.Sourceobject - Throws:
SOAPException- if the implementation cannot convert the specifiedSourceobject- See Also:
-