SOAPHeader (Java EE 5)

Java EE API


javax.xml.soap Interface SOAPHeader

All Superinterfaces:
Element, Node, SOAPElement

public interface SOAPHeader
extends SOAPElement

Implements: SOAPElement

SOAP 头元素的表示形式。SOAP 头元素由能影响消息提供者处理特定于应用程序内容的方式的 XML 数据组成。例如,事务语义、验证信息等,都可以被指定为 SOAPHeader 对象的内容。

SOAPEnvelope 对象默认包含一个空 SOAPHeader 对象。如果不需要 SOAPHeader 对象(可选),则可以使用以下代码行检索和删除该对象。变量 se 是一个 SOAPEnvelope 对象。

se.getHeader().detachNode();
 
SOAPHeader 对象是使用 SOAPEnvelopeaddHeader 方法创建的。只有在移除现有的头之后,才能调用此方法创建新头并将其添加到信封中。
se.getHeader().detachNode();
SOAPHeader sh = se.addHeader();
 

SOAPHeader 对象只能将 SOAPHeaderElement 对象作为其直接子级。方法 addHeaderElement 创建一个新 HeaderElement 对象并将其添加到 SOAPHeader 对象。在以下代码行中,方法 addHeaderElement 的参数是一个 Name 对象,该对象是新 HeaderElement 对象的名称。

SOAPHeaderElement shElement = sh.addHeaderElement(name);
 
英文文档:

A representation of the SOAP header element. A SOAP header element consists of XML data that affects the way the application-specific content is processed by the message provider. For example, transaction semantics, authentication information, and so on, can be specified as the content of a SOAPHeader object.

A SOAPEnvelope object contains an empty SOAPHeader object by default. If the SOAPHeader object, which is optional, is not needed, it can be retrieved and deleted with the following line of code. The variable se is a SOAPEnvelope object.

      se.getHeader().detachNode();
 
A SOAPHeader object is created with the SOAPEnvelope method addHeader. This method, which creates a new header and adds it to the envelope, may be called only after the existing header has been removed.
      se.getHeader().detachNode();
      SOAPHeader sh = se.addHeader();
 

A SOAPHeader object can have only SOAPHeaderElement objects as its immediate children. The method addHeaderElement creates a new HeaderElement object and adds it to the SOAPHeader object. In the following line of code, the argument to the method addHeaderElement is a Name object that is the name for the new HeaderElement object.

      SOAPHeaderElement shElement = sh.addHeaderElement(name);
 

See Also:
SOAPHeaderElement

Field Summary
 
Fields inherited from interface org.w3c.dom.Node
 
Fields inherited from interface org.w3c.dom.Node
 
Method Summary
 SOAPHeaderElement
 SOAPHeaderElement
 SOAPHeaderElement
 SOAPHeaderElement
 SOAPHeaderElement
 SOAPHeaderElement
 Iterator
 Iterator
 Iterator
 Iterator
 Iterator
 
Methods inherited from interface javax.xml.soap.SOAPElement
 
Methods inherited from interface javax.xml.soap.Node
 
Methods inherited from interface org.w3c.dom.Node
 
Methods inherited from interface org.w3c.dom.Element
 
Methods inherited from interface org.w3c.dom.Node
 

Method Detail

public SOAPHeaderElement addHeaderElement(Name name) throws SOAPException
创建使用指定名称初始化的新的 SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。
name 带有新 SOAPHeaderElement 对象名称的 Name 对象
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误
See also addHeaderElement(javax.xml.namespace.QName)
英文文档:

addHeaderElement

SOAPHeaderElement addHeaderElement(Name name)
                                   throws SOAPException
Creates a new SOAPHeaderElement object initialized with the specified name and adds it to this SOAPHeader object.

Parameters:
name - a Name object with the name of the new SOAPHeaderElement object
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs
See Also:
addHeaderElement(javax.xml.namespace.QName)

public SOAPHeaderElement addHeaderElement(javax.xml.namespace.QName qname) throws SOAPException
创建使用指定 qname 初始化的新的 SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。
qname 带有新 SOAPHeaderElement 对象 qname 的 QName 对象
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误
sinceSAAJ 1.3
See also addHeaderElement(Name)
英文文档:

addHeaderElement

SOAPHeaderElement addHeaderElement(QName qname)
                                   throws SOAPException
Creates a new SOAPHeaderElement object initialized with the specified qname and adds it to this SOAPHeader object.

Parameters:
qname - a QName object with the qname of the new SOAPHeaderElement object
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs
Since:
SAAJ 1.3
See Also:
addHeaderElement(Name)

public java.util.Iterator<E> examineMustUnderstandHeaderElements(String actor)
返回可在此 SOAPHeader 对象中所有符合以下条件的 SOAPHeaderElement 对象上进行迭代的 Iterator:具有指定的 actor 以及一个值等于 true 的 MustUnderstand 属性。

在 SOAP 1.2 中,env:actor 属性应替换为 env:role 属性,但实质上语义是相同的。

actor 一个 String,给出要搜索的 actor/role 的 URI
return 一个 Iterator 对象,可在所有符合以下条件的 SOAPHeaderElement 对象上进行迭代:包含指定的 actor / role 并标记为 MustUnderstand
sinceSAAJ 1.2
See also examineHeaderElements, extractHeaderElements, URI_SOAP_ACTOR_NEXT

英文文档:

examineMustUnderstandHeaderElements

Iterator examineMustUnderstandHeaderElements(String actor)
Returns an Iterator over all the SOAPHeaderElement objects in this SOAPHeader object that have the specified actor and that have a MustUnderstand attribute whose value is equivalent to true.

In SOAP 1.2 the env:actor attribute is replaced by the env:role attribute, but with essentially the same semantics.

Parameters:
actor - a String giving the URI of the actor / role for which to search
Returns:
an Iterator object over all the SOAPHeaderElement objects that contain the specified actor / role and are marked as MustUnderstand
Since:
SAAJ 1.2
See Also:
examineHeaderElements(java.lang.String), extractHeaderElements(java.lang.String), SOAPConstants.URI_SOAP_ACTOR_NEXT

public java.util.Iterator<E> examineHeaderElements(String actor)
返回可在此 SOAPHeader 对象中具有指定的 actorSOAPHeaderElement 对象上进行迭代的 Iteratoractor 是一个全局属性,指示消息到达其最终接收者之前应对该消息进行处理的中间参与方。actor 接收并处理消息,然后将该消息发送到下一个 actor。默认 actor 是消息的最终预定接收方,所以如果 SOAPHeader 对象中没有包括 actor 属性,那么 message 将与消息正文一起发送到最终接收者。

在 SOAP 1.2 中,env:actor 属性应替换为 env:role 属性,但实质上语义是相同的。

actor 一个 String,给出要搜索的 actor/role 的 URI
return 一个 Iterator 对象,可在所有包含指定 actor / roleSOAPHeaderElement 对象上进行迭代
See also extractHeaderElements, URI_SOAP_ACTOR_NEXT

英文文档:

examineHeaderElements

Iterator examineHeaderElements(String actor)
Returns an Iterator over all the SOAPHeaderElement objects in this SOAPHeader object that have the specified actor. An actor is a global attribute that indicates the intermediate parties that should process a message before it reaches its ultimate receiver. An actor receives the message and processes it before sending it on to the next actor. The default actor is the ultimate intended recipient for the message, so if no actor attribute is included in a SOAPHeader object, it is sent to the ultimate receiver along with the message body.

In SOAP 1.2 the env:actor attribute is replaced by the env:role attribute, but with essentially the same semantics.

Parameters:
actor - a String giving the URI of the actor / role for which to search
Returns:
an Iterator object over all the SOAPHeaderElement objects that contain the specified actor / role
See Also:
extractHeaderElements(java.lang.String), SOAPConstants.URI_SOAP_ACTOR_NEXT

public java.util.Iterator<E> extractHeaderElements(String actor)
返回可在此 SOAPHeader 对象中所有具有指定 actorSOAPHeaderElement 对象上进行迭代的 Iterator,并将这些 SOAPHeaderElement 对象从此 SOAPHeader 对象中分离出来。

此方法允许 actor 处理并移除适用于它的 SOAPHeader 对象部分,然后将该消息发送到下一个 actor。

在 SOAP 1.2 中,env:actor 属性应替换为 env:role 属性,但实质上语义是相同的。

actor 一个 String,给出要搜索的 actor/role 的 URI
return 一个 Iterator 对象,可在所有包含指定 actor / roleSOAPHeaderElement 对象上进行迭代
See also examineHeaderElements, URI_SOAP_ACTOR_NEXT

英文文档:

extractHeaderElements

Iterator extractHeaderElements(String actor)
Returns an Iterator over all the SOAPHeaderElement objects in this SOAPHeader object that have the specified actor and detaches them from this SOAPHeader object.

This method allows an actor to process the parts of the SOAPHeader object that apply to it and to remove them before passing the message on to the next actor.

In SOAP 1.2 the env:actor attribute is replaced by the env:role attribute, but with essentially the same semantics.

Parameters:
actor - a String giving the URI of the actor / role for which to search
Returns:
an Iterator object over all the SOAPHeaderElement objects that contain the specified actor / role
See Also:
examineHeaderElements(java.lang.String), SOAPConstants.URI_SOAP_ACTOR_NEXT

public SOAPHeaderElement addNotUnderstoodHeaderElement(javax.xml.namespace.QName name) throws SOAPException
创建使用指定名称初始化的新的 NotUnderstood SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。只有 SOAP 1.2 支持此操作。
name 带有不可理解的 SOAPHeaderElement 对象名称的 QName 对象。
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误。
ThrowsUnsupportedOperationException: 如果这是一个 SOAP 1.1 Header。
sinceSAAJ 1.3
英文文档:

addNotUnderstoodHeaderElement

SOAPHeaderElement addNotUnderstoodHeaderElement(QName name)
                                                throws SOAPException
Creates a new NotUnderstood SOAPHeaderElement object initialized with the specified name and adds it to this SOAPHeader object. This operation is supported only by SOAP 1.2.

Parameters:
name - a QName object with the name of the SOAPHeaderElement object that was not understood.
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs.
UnsupportedOperationException - if this is a SOAP 1.1 Header.
Since:
SAAJ 1.3

public SOAPHeaderElement addUpgradeHeaderElement(java.util.Iterator<E> supportedSOAPURIs) throws SOAPException
创建使用指定的 SOAP URI 支持列表初始化的新的 Upgrade SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。SOAP 1.1 头和 SOAP 1.2 头上都支持此操作。
supportedSOAPURIs 带有受支持 SOAP 版本 URI 的 Iterator 对象。
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误。
sinceSAAJ 1.3
英文文档:

addUpgradeHeaderElement

SOAPHeaderElement addUpgradeHeaderElement(Iterator supportedSOAPURIs)
                                          throws SOAPException
Creates a new Upgrade SOAPHeaderElement object initialized with the specified List of supported SOAP URIs and adds it to this SOAPHeader object. This operation is supported on both SOAP 1.1 and SOAP 1.2 header.

Parameters:
supportedSOAPURIs - an Iterator object with the URIs of SOAP versions supported.
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs.
Since:
SAAJ 1.3

public SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris) throws SOAPException
创建使用指定 SOAP URI 支持数组初始化的新的 Upgrade SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。SOAP 1.1 头和 SOAP 1.2 头上都支持此操作。
supportedSoapUris 受支持 SOAP 版本的 URI 数组
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误。
sinceSAAJ 1.3
英文文档:

addUpgradeHeaderElement

SOAPHeaderElement addUpgradeHeaderElement(String[] supportedSoapUris)
                                          throws SOAPException
Creates a new Upgrade SOAPHeaderElement object initialized with the specified array of supported SOAP URIs and adds it to this SOAPHeader object. This operation is supported on both SOAP 1.1 and SOAP 1.2 header.

Parameters:
supportedSoapUris - an array of the URIs of SOAP versions supported.
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs.
Since:
SAAJ 1.3

public SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri) throws SOAPException
创建使用指定受支持 SOAP URI 初始化的新的 Upgrade SOAPHeaderElement 对象,并将其添加到此 SOAPHeader 对象。SOAP 1.1 头和 SOAP 1.2 头上都支持此操作。
supportedSoapUri 受支持 SOAP 版本的 URI。
return 插入此 SOAPHeader 对象的新的 SOAPHeaderElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误。
sinceSAAJ 1.3
英文文档:

addUpgradeHeaderElement

SOAPHeaderElement addUpgradeHeaderElement(String supportedSoapUri)
                                          throws SOAPException
Creates a new Upgrade SOAPHeaderElement object initialized with the specified supported SOAP URI and adds it to this SOAPHeader object. This operation is supported on both SOAP 1.1 and SOAP 1.2 header.

Parameters:
supportedSoapUri - the URI of SOAP the version that is supported.
Returns:
the new SOAPHeaderElement object that was inserted into this SOAPHeader object
Throws:
SOAPException - if a SOAP error occurs.
Since:
SAAJ 1.3

public java.util.Iterator<E> examineAllHeaderElements()
返回可在此 SOAPHeader 对象中所有 SOAPHeaderElement 对象上进行迭代的 Iterator
return 一个 Iterator 对象,可在此 SOAPHeader 对象包含的所有 SOAPHeaderElement 对象上进行迭代
sinceSAAJ 1.2
See also extractAllHeaderElements
英文文档:

examineAllHeaderElements

Iterator examineAllHeaderElements()
Returns an Iterator over all the SOAPHeaderElement objects in this SOAPHeader object.

Returns:
an Iterator object over all the SOAPHeaderElement objects contained by this SOAPHeader
Since:
SAAJ 1.2
See Also:
extractAllHeaderElements()

public java.util.Iterator<E> extractAllHeaderElements()
返回可在此 SOAPHeader 对象中所有 SOAPHeaderElement 对象上进行迭代的 Iterator,并将这些 SOAPHeaderElement 对象从此 SOAPHeader 对象中分离出来。
return 一个 Iterator 对象,可在此 SOAPHeader 对象包含的所有 SOAPHeaderElement 对象上进行迭代
sinceSAAJ 1.2
See also examineAllHeaderElements
英文文档:

extractAllHeaderElements

Iterator extractAllHeaderElements()
Returns an Iterator over all the SOAPHeaderElement objects in this SOAPHeader object and detaches them from this SOAPHeader object.

Returns:
an Iterator object over all the SOAPHeaderElement objects contained by this SOAPHeader
Since:
SAAJ 1.2
See Also:
examineAllHeaderElements()


Submit a bug or feature

Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.

一看就知道只有菜鸟才干这么无知的事啦。

PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!