SOAPBody (Java EE 5)

Java EE API


javax.xml.soap Interface SOAPBody

All Superinterfaces:
Element, Node, SOAPElement

public interface SOAPBody
extends SOAPElement

Implements: SOAPElement

表示 SOAP 消息中 SOAP 正文元素内容的对象。SOAP 正文元素由能影响特定于应用程序内容的处理方式的 XML 数据组成。

SOAPBody 对象包含了 SOAPBodyElement 对象,后者具有 SOAP 正文的内容。携带状态和/或错误信息的 SOAPFault 对象是 SOAPBodyElement 对象的一个示例。

英文文档:

An object that represents the contents of the SOAP body element in a SOAP message. A SOAP body element consists of XML data that affects the way the application-specific content is processed.

A SOAPBody object contains SOAPBodyElement objects, which have the content for the SOAP body. A SOAPFault object, which carries status and/or error information, is an example of a SOAPBodyElement object.

See Also:
SOAPFault

Field Summary
 
Fields inherited from interface org.w3c.dom.Node
 
Fields inherited from interface org.w3c.dom.Node
 
Method Summary
 SOAPBodyElement
 SOAPBodyElement
 SOAPBodyElement
 SOAPFault
 SOAPFault
 SOAPFault
 SOAPFault
 SOAPFault
 Document
 SOAPFault
 boolean
 
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 SOAPFault addFault() throws SOAPException
创建新的 SOAPFault 对象,并将其添加到此 SOAPBody 对象。新的 SOAPFault 会将强制性 (mandatory) 子元素设置为默认值。SOAPFault 的类型可以是 SOAP 1.1 或 SOAP 1.2 SOAPFault,这取决于创建 MessageFactory 实例时指定的 protocol

一个 SOAPBody 最多只能包含一个 SOAPFault 子元素。

return 新的 SOAPFault 对象
ThrowsSOAPException: 如果存在 SOAP 错误

英文文档:

addFault

SOAPFault addFault()
                   throws SOAPException
Creates a new SOAPFault object and adds it to this SOAPBody object. The new SOAPFault will have default values set for the mandatory child elements. The type of the SOAPFault will be a SOAP 1.1 or a SOAP 1.2 SOAPFault depending on the protocol specified while creating the MessageFactory instance.

A SOAPBody may contain at most one SOAPFault child element.

Returns:
the new SOAPFault object
Throws:
SOAPException - if there is a SOAP error

public SOAPFault addFault(Name faultCode, String faultString, java.util.Locale locale) throws SOAPException
创建新的 SOAPFault 对象,并将其添加到此 SOAPBody 对象。SOAPFault 的类型可以是 SOAP 1.1 或 SOAP 1.2 SOAPFault,这取决于创建 MessageFactory 实例时指定的 protocol

对于 SOAP 1.2,faultCode 参数是 Fault/Code/Value 元素的值,faultString 参数是 Fault/Reason/Text 元素的值。对于 SOAP 1.1,faultCode 参数是 faultcode 元素的值,faultString 参数是 faultstring 元素的值。

一个 SOAPBody 最多只能包含一个 SOAPFault 子元素。

faultCode Name 对象,给出要设置的错误代码;必须是正使用的 SOAP 规范的版本中定义的错误代码之一
faultString 一个 String,给出对错误的解释
locale java.util.Locale 对象,指示 faultString 的本地语言
return 新的 SOAPFault 对象
ThrowsSOAPException: 如果存在 SOAP 错误
sinceSAAJ 1.2
See also setFaultCode, setFaultString

英文文档:

addFault

SOAPFault addFault(Name faultCode,
                   String faultString,
                   Locale locale)
                   throws SOAPException
Creates a new SOAPFault object and adds it to this SOAPBody object. The type of the SOAPFault will be a SOAP 1.1 or a SOAP 1.2 SOAPFault depending on the protocol specified while creating the MessageFactory instance.

For SOAP 1.2 the faultCode parameter is the value of the Fault/Code/Value element and the faultString parameter is the value of the Fault/Reason/Text element. For SOAP 1.1 the faultCode parameter is the value of the faultcode element and the faultString parameter is the value of the faultstring element.

A SOAPBody may contain at most one SOAPFault child element.

Parameters:
faultCode - a Name object giving the fault code to be set; must be one of the fault codes defined in the Version of SOAP specification in use
faultString - a String giving an explanation of the fault
locale - a Locale object indicating the native language of the faultString
Returns:
the new SOAPFault object
Throws:
SOAPException - if there is a SOAP error
Since:
SAAJ 1.2
See Also:
SOAPFault.setFaultCode(javax.xml.soap.Name), SOAPFault.setFaultString(java.lang.String)

public SOAPFault addFault(javax.xml.namespace.QName faultCode, String faultString, java.util.Locale locale) throws SOAPException
创建新的 SOAPFault 对象,并将其添加到此 SOAPBody 对象。SOAPFault 的类型可以是 SOAP 1.1 或 SOAP 1.2 SOAPFault,这取决于创建 MessageFactory 实例时指定的 protocol

对于 SOAP 1.2,faultCode 参数是 Fault/Code/Value 元素的值,faultString 参数是 Fault/Reason/Text 元素的值。对于 SOAP 1.1,faultCode 参数是 faultcode 元素的值,faultString 参数是 faultstring 元素的值。

一个 SOAPBody 最多只能包含一个 SOAPFault 子元素。

faultCode QName 对象,给出要设置的错误代码;必须是正使用的 SOAP 规范的版本中定义的错误代码之一。
faultString String,给出错误的解释
locale Locale 对象,指示 faultString 的本地语言
return 新的 SOAPFault 对象
ThrowsSOAPException: 如果存在 SOAP 错误
sinceSAAJ 1.3
See also setFaultCode, setFaultString, addFault(Name faultCode, String faultString, Locale locale)

英文文档:

addFault

SOAPFault addFault(QName faultCode,
                   String faultString,
                   Locale locale)
                   throws SOAPException
Creates a new SOAPFault object and adds it to this SOAPBody object. The type of the SOAPFault will be a SOAP 1.1 or a SOAP 1.2 SOAPFault depending on the protocol specified while creating the MessageFactory instance.

For SOAP 1.2 the faultCode parameter is the value of the Fault/Code/Value element and the faultString parameter is the value of the Fault/Reason/Text element. For SOAP 1.1 the faultCode parameter is the value of the faultcode element and the faultString parameter is the value of the faultstring element.

A SOAPBody may contain at most one SOAPFault child element.

Parameters:
faultCode - a QName object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use.
faultString - a String giving an explanation of the fault
locale - a Locale object indicating the native language of the faultString
Returns:
the new SOAPFault object
Throws:
SOAPException - if there is a SOAP error
Since:
SAAJ 1.3
See Also:
SOAPFault.setFaultCode(javax.xml.soap.Name), SOAPFault.setFaultString(java.lang.String), addFault(Name faultCode, String faultString, Locale locale)

public SOAPFault addFault(Name faultCode, String faultString) throws SOAPException
创建新的 SOAPFault 对象,并将其添加到此 SOAPBody 对象。SOAPFault 的类型可以是 SOAP 1.1 或 SOAP 1.2 SOAPFault,这取决于创建 MessageFactory 实例时指定的 protocol

对于 SOAP 1.2,faultCode 参数是 Fault/Code/Value 元素的值,faultString 参数是 Fault/Reason/Text 元素的值。对于 SOAP 1.1,faultCode 参数是 faultcode 元素的值,faultString 参数是 faultstring 元素的值。

如果是 SOAP 1.2 错误,Fault/Reason/Text 元素上强制性 xml:lang 属性的默认值将设置为 java.util.Locale.getDefault()

一个 SOAPBody 最多只能包含一个 SOAPFault 子元素。

faultCode Name 对象,给出要设置的错误代码;必须是正使用的 SOAP 规范的版本中定义的错误代码之一
faultString String,给出错误的解释
return 新的 SOAPFault 对象
ThrowsSOAPException: 如果存在 SOAP 错误
sinceSAAJ 1.2
See also setFaultCode, setFaultString

英文文档:

addFault

SOAPFault addFault(Name faultCode,
                   String faultString)
                   throws SOAPException
Creates a new SOAPFault object and adds it to this SOAPBody object. The type of the SOAPFault will be a SOAP 1.1 or a SOAP 1.2 SOAPFault depending on the protocol specified while creating the MessageFactory instance.

For SOAP 1.2 the faultCode parameter is the value of the Fault/Code/Value element and the faultString parameter is the value of the Fault/Reason/Text element. For SOAP 1.1 the faultCode parameter is the value of the faultcode element and the faultString parameter is the value of the faultstring element.

In case of a SOAP 1.2 fault, the default value for the mandatory xml:lang attribute on the Fault/Reason/Text element will be set to java.util.Locale.getDefault()

A SOAPBody may contain at most one SOAPFault child element.

Parameters:
faultCode - a Name object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use
faultString - a String giving an explanation of the fault
Returns:
the new SOAPFault object
Throws:
SOAPException - if there is a SOAP error
Since:
SAAJ 1.2
See Also:
SOAPFault.setFaultCode(javax.xml.soap.Name), SOAPFault.setFaultString(java.lang.String)

public SOAPFault addFault(javax.xml.namespace.QName faultCode, String faultString) throws SOAPException
创建新的 SOAPFault 对象,并将其添加到此 SOAPBody 对象。SOAPFault 的类型可以是 SOAP 1.1 或 SOAP 1.2 SOAPFault,这取决于创建 MessageFactory 实例时指定的 protocol

对于 SOAP 1.2,faultCode 参数是 Fault/Code/Value 元素的值,faultString 参数是 Fault/Reason/Text 元素的值。对于 SOAP 1.1,faultCode 参数是 faultcode 元素的值,faultString 参数是 faultstring 元素的值。

如果是 SOAP 1.2 错误,Fault/Reason/Text 元素上强制性 xml:lang 属性的默认值将设置为 java.util.Locale.getDefault()

一个 SOAPBody 最多只能包含一个 SOAPFault 子元素

faultCode QName 对象,给出要设置的错误代码;必须是正使用的 SOAP 规范的版本中定义的错误代码之一
faultString String,给出错误的解释
return 新的 SOAPFault 对象
ThrowsSOAPException: 如果存在 SOAP 错误
sinceSAAJ 1.3
See also setFaultCode, setFaultString, addFault(Name faultCode, String faultString)

英文文档:

addFault

SOAPFault addFault(QName faultCode,
                   String faultString)
                   throws SOAPException
Creates a new SOAPFault object and adds it to this SOAPBody object. The type of the SOAPFault will be a SOAP 1.1 or a SOAP 1.2 SOAPFault depending on the protocol specified while creating the MessageFactory instance.

For SOAP 1.2 the faultCode parameter is the value of the Fault/Code/Value element and the faultString parameter is the value of the Fault/Reason/Text element. For SOAP 1.1 the faultCode parameter is the value of the faultcode element and the faultString parameter is the value of the faultstring element.

In case of a SOAP 1.2 fault, the default value for the mandatory xml:lang attribute on the Fault/Reason/Text element will be set to java.util.Locale.getDefault()

A SOAPBody may contain at most one SOAPFault child element

Parameters:
faultCode - a QName object giving the fault code to be set; must be one of the fault codes defined in the version of SOAP specification in use
faultString - a String giving an explanation of the fault
Returns:
the new SOAPFault object
Throws:
SOAPException - if there is a SOAP error
Since:
SAAJ 1.3
See Also:
SOAPFault.setFaultCode(javax.xml.soap.Name), SOAPFault.setFaultString(java.lang.String), addFault(Name faultCode, String faultString)

public boolean hasFault()
指示此 SOAPBody 对象中是否存在 SOAPFault 对象。
return 如果此 SOAPBody 对象中存在 SOAPFault 对象,则返回 true;否则返回 false
英文文档:

hasFault

boolean hasFault()
Indicates whether a SOAPFault object exists in this SOAPBody object.

Returns:
true if a SOAPFault object exists in this SOAPBody object; false otherwise

public SOAPFault getFault()
返回此 SOAPBody 对象中的 SOAPFault 对象。
returnSOAPBody 对象中的 SOAPFault 对象(如果存在);若不存在,则返回 null。
英文文档:

getFault

SOAPFault getFault()
Returns the SOAPFault object in this SOAPBody object.

Returns:
the SOAPFault object in this SOAPBody object if present, null otherwise.

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

addBodyElement

SOAPBodyElement addBodyElement(Name name)
                               throws SOAPException
Creates a new SOAPBodyElement object with the specified name and adds it to this SOAPBody object.

Parameters:
name - a Name object with the name for the new SOAPBodyElement object
Returns:
the new SOAPBodyElement object
Throws:
SOAPException - if a SOAP error occurs
See Also:
addBodyElement(javax.xml.namespace.QName)

public SOAPBodyElement addBodyElement(javax.xml.namespace.QName qname) throws SOAPException
使用指定 QName 创建新的 SOAPBodyElement 对象,并将其添加到此 SOAPBody 对象。
qname QName 对象,带有新 SOAPBodyElement 对象的名称
return 新的 SOAPBodyElement 对象
ThrowsSOAPException: 如果发生 SOAP 错误
sinceSAAJ 1.3
See also addBodyElement(Name)
英文文档:

addBodyElement

SOAPBodyElement addBodyElement(QName qname)
                               throws SOAPException
Creates a new SOAPBodyElement object with the specified QName and adds it to this SOAPBody object.

Parameters:
qname - a QName object with the qname for the new SOAPBodyElement object
Returns:
the new SOAPBodyElement object
Throws:
SOAPException - if a SOAP error occurs
Since:
SAAJ 1.3
See Also:
addBodyElement(Name)

public SOAPBodyElement addDocument(org.w3c.dom.Document document) throws SOAPException
将 DOM org.w3c.dom.Document 的根节点添加到此 SOAPBody 对象。

调用此方法会使 document 参数失效。在调用 addDocument 时,客户端应用程序应丢弃所有对此 Document 及其内容的引用。继续使用此类引用的应用程序将产生不确定的行为。

document Document 对象,该对象的根节点将被添加到此 SOAPBody
return 表示被添加根节点的 SOAPBodyElement
ThrowsSOAPException: 如果无法添加 Document
sinceSAAJ 1.2

英文文档:

addDocument

SOAPBodyElement addDocument(Document document)
                            throws SOAPException
Adds the root node of the DOM Document to this SOAPBody object.

Calling this method invalidates the document parameter. The client application should discard all references to this Document and its contents upon calling addDocument. The behavior of an application that continues to use such references is undefined.

Parameters:
document - the Document object whose root node will be added to this SOAPBody.
Returns:
the SOAPBodyElement that represents the root node that was added.
Throws:
SOAPException - if the Document cannot be added
Since:
SAAJ 1.2

public org.w3c.dom.Document extractContentAsDocument() throws SOAPException
创建新的 DOM org.w3c.dom.Document,并将此 SOAPBody 的第一个子元素设置为它的文档元素。子 SOAPElement 作为进程的一部分被移除。
return SOAPBody 内容的 org.w3c.dom.Document 表示形式。
ThrowsSOAPException: 如果不存在任何 SOAPBody 的子 SOAPElement
sinceSAAJ 1.3
英文文档:

extractContentAsDocument

Document extractContentAsDocument()
                                  throws SOAPException
Creates a new DOM Document and sets the first child of this SOAPBody as it's document element. The child SOAPElement is removed as part of the process.

Returns:
the Document representation of the SOAPBody content.
Throws:
SOAPException - if there is not exactly one child SOAPElement of the SOAPBody.
Since:
SAAJ 1.3


Submit a bug or feature

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

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

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