|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
javax.xml.soap Class SOAPPart
java.lang.Object javax.xml.soap.SOAPPart
SOAPMessage
对象中特定于 SOAP 部分的容器。所有消息都必须有一个 SOAP 部分,因此 SOAPMessage
对象在创建之后将自动获得一个 SOAPPart
对象。
SOAPPart
对象是一个 MIME 部分,并具有 MIME 头 Content-Id、Content-Location 和 Content-Type。因为 Content-Type 的值必须为 "text/xml",所以 SOAPPart
对象自动获得 Content-Type 的 MIME 头,且 Content-Type 值已设置为 "text/xml"。消息 SOAP 部分中的所有数据都必须是 XML 格式,因此值必须为 "text/xml"。不是 "text/xml" 类型的内容不能在 SOAPPart
对象中,而必须在 AttachmentPart
对象中。
发送消息时,其 SOAP 部分必须将 MIME 头 Content-Type 设置为 "text/xml"。或者换个角度来说,已收到消息的 SOAP 部分必须具有值为 "text/xml" 的 MIME 头 Content-Type。
客户端可以通过调用方法 SOAPMessage.getSOAPPart
来访问 SOAPMessage
对象的 SOAPPart
对象。以下代码行(其中 message
是一个 SOAPMessage
对象)检索消息的 SOAP 部分。
SOAPPart soapPart = message.getSOAPPart();
SOAPPart
对象包含一个 SOAPEnvelope
对象,SOAPEnvelope
对象包含一个 SOAPBody
对象和一个 SOAPHeader
对象。SOAPPart
的 getEnvelope
方法可以用于检索 SOAPEnvelope
对象。
The container for the SOAP-specific portion of a 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.
Field Summary |
---|
Constructor Summary | |
---|---|
SOAPPart()
|
Method Summary | |
---|---|
abstract void |
addMimeHeader(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 this
SOAPPart 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 this
SOAPEnvelope 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(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 |
Methods 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 |
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, 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 Detail |
---|
public
SOAPPart()
英文文档:
SOAPPart
public SOAPPart()
Method Detail |
---|
abstract public SOAPEnvelope
getEnvelope() throws SOAPException
获取与此 SOAPPart
对象关联的 SOAPEnvelope
对象。获取 SOAP 信封后,可以用此方法来获取它的内容。
return |
此 SOAPPart 对象的 SOAPEnvelope 对象 |
Throws | SOAPException: 如果存在 SOAP 错误 |
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
- if there is a SOAP error
public String
getContentId()
检索名为 "Content-Id" 的 MIME 头的值。
return |
一个 String ,给出名为 "Content-Id" 的 MIME 头的值 |
See also | setContentId |
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)
public String
getContentLocation()
检索名为 "Content-Location" 的 MIME 头的值。
return |
一个 String ,给出名为 "Content-Location" 的 MIME 头的值 |
See also | setContentLocation |
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)
public void
setContentId(String contentId)
将名为 "Content-Id" 的 MIME 头的值设置为给定 String
。
contentId |
一个 String ,给出 MIME 头 "Content-Id" 的值 |
Throws | IllegalArgumentException: 如果在设置内容 id 时出现问题 |
See also | getContentId |
setContentId
public void setContentId(String contentId)
- Sets the value of the MIME header named "Content-Id"
to the given
String
. - Parameters:
contentId
- aString
giving the value of the MIME header "Content-Id"- Throws:
IllegalArgumentException
- if there is a problem in setting the content id- See Also:
getContentId()
public void
setContentLocation(String contentLocation)
将 MIME 头 "Content-Location" 的值设置为给定 String
。
contentLocation |
一个 String ,给出 MIME 头 "Content-Location" 的值 |
Throws | IllegalArgumentException: 如果在设置内容位置时出现问题。 |
See also | getContentLocation |
setContentLocation
public void setContentLocation(String contentLocation)
- Sets the value of the MIME header "Content-Location"
to the given
String
. - Parameters:
contentLocation
- aString
giving the value of the MIME header "Content-Location"- Throws:
IllegalArgumentException
- if there is a problem in setting the content location.- See Also:
getContentLocation()
abstract public void
removeMimeHeader(String header)
移除所有与给定名称匹配的 MIME 头。
header |
一个 String ,给出要移除的 MIME 头的名称 |
removeMimeHeader
public abstract void removeMimeHeader(String header)
- Removes all MIME headers that match the given name.
- Parameters:
header
- aString
giving the name of the MIME header(s) to be removed
abstract public void
removeAllMimeHeaders()
移除此 SOAPEnvelope
对象的所有 MimeHeader
对象。
英文文档:
removeAllMimeHeaders
public abstract void removeAllMimeHeaders()
- Removes all the
MimeHeader
objects for thisSOAPEnvelope
object.
abstract public String[]
getMimeHeader(String name)
获取此 SOAPPart
对象中所有由给定 String
标识的 MimeHeader
对象的值。
name | 头的名称;示例:"Content-Type" |
return |
一个 String 数组,给出所有指定头的值 |
See also | setMimeHeader |
getMimeHeader
public abstract String[] getMimeHeader(String name)
- Gets all the values of the
MimeHeader
object in thisSOAPPart
object that is identified by the givenString
. - 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)
abstract public void
setMimeHeader(String name, String value)
将与给定头名称匹配的第一个头条目的值更改为给定值,如果现有头都不匹配,则添加一个带有给定名称和值的新头。如果有匹配的头,则此方法清除第一个匹配头的所有现有值,并设置为给定的值。如果多个头都具有给定名称,则此方法移除第一个匹配头之后的所有匹配头。
注意,RFC822 头只能包含 US-ASCII 字符。
name |
一个 String ,给出要搜索的头的名称 |
value |
一个 String ,给出要设置的值。此值将替换第一个匹配头(如果有)的当前值。如果没有匹配的头,则此值将是新 MimeHeader 对象的值。 |
Throws | IllegalArgumentException: 如果指定的 MIME 头名称或值存在问题 |
See also | getMimeHeader |
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
- aString
giving the header name for which to searchvalue
- aString
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 newMimeHeader
object.- Throws:
IllegalArgumentException
- if there was a problem with the specified mime header name or value- See Also:
getMimeHeader(java.lang.String)
abstract public void
addMimeHeader(String name, String value)
使用指定名称和值创建 MimeHeader
对象,并将其添加到此 SOAPPart
对象。如果已经存在带有指定名称的 MimeHeader
,则此方法将指定值添加到已经存在的值中。
注意,RFC822 头只能包含 US-ASCII 字符。
name |
一个 String ,给出头名称 |
value |
一个 String ,给出要设置或要添加的值 |
Throws | IllegalArgumentException: 如果指定的 MIME 头名称或值存在问题 |
addMimeHeader
public abstract void addMimeHeader(String name, String value)
- Creates a
MimeHeader
object with the specified name and value and adds it to thisSOAPPart
object. If aMimeHeader
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
- aString
giving the header namevalue
- aString
giving the value to be set or added- Throws:
IllegalArgumentException
- if there was a problem with the specified mime header name or value
abstract public java.util.Iterator<E>
getAllMimeHeaders()
以可在 MimeHeader
对象上进行迭代的迭代器形式,检索此 SOAPPart
对象的所有头。
return |
一个 Iterator 对象,具有此 SOAPPart 对象的所有 Mime 头
|
getAllMimeHeaders
public abstract Iterator getAllMimeHeaders()
- Retrieves all the headers for this
SOAPPart
object as an iterator over theMimeHeader
objects. - Returns:
- an
Iterator
object with all of the Mime headers for thisSOAPPart
object
abstract public java.util.Iterator<E>
getMatchingMimeHeaders(String[] names)
检索匹配给定数组中名称的所有 MimeHeader
对象。
names |
一个 String 数组,带有要返回的 Mime 头的名称 |
return |
以 Iterator 对象形式返回的与给定数组中任一名称匹配的所有 MIME 头
|
getMatchingMimeHeaders
public abstract Iterator getMatchingMimeHeaders(String[] names)
- Retrieves all
MimeHeader
objects that match a name in the given array. - Parameters:
names
- aString
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
abstract public java.util.Iterator<E>
getNonMatchingMimeHeaders(String[] names)
检索所有名称不匹配给定数组中任一名称的 MimeHeader
对象。
names |
一个 String 数组,带有不要返回的 Mime 头的名称 |
return |
此 SOAPPart 对象中与给定数组中任一名称匹配的 MIME 头之外的所有 MIME 头。以 Iterator 对象的形式返回不匹配的 MIME 头。
|
getNonMatchingMimeHeaders
public abstract Iterator getNonMatchingMimeHeaders(String[] names)
- Retrieves all
MimeHeader
objects whose name does not match a name in the given array. - Parameters:
names
- aString
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.
abstract public void
setContent(javax.xml.transform.Source source) throws SOAPException
使用取自给定 Source
对象的数据设置 SOAPEnvelope
对象的内容。此 Source
必须包含一个有效的 SOAP 文档。
source |
javax.xml.transform.Source 对象,带有要发送的数据 |
Throws | SOAPException: 如果在设置源时出现错误。 |
See also | getContent |
setContent
public abstract void setContent(Source source) throws SOAPException
- Sets the content of the
SOAPEnvelope
object with the data from the givenSource
object. ThisSource
must contain a valid SOAP document. - Parameters:
source
- thejavax.xml.transform.Source
object with the data to be set- Throws:
SOAPException
- if there is a problem in setting the source- See Also:
getContent()
abstract public javax.xml.transform.Source
getContent() throws SOAPException
以 JAXP Source
对象的形式返回 SOAPEnvelope 的内容。
return |
javax.xml.transform.Source 对象形式的内容
|
Throws | SOAPException:
如果实现无法转换指定的 Source 对象 |
See also | setContent |
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
- if the implementation cannot convert the specifiedSource
object- See Also:
setContent(javax.xml.transform.Source)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!