SOAPConnection

   
SOAPBodyElement javax.xml.soap

SAAJ 1.1; JWSDP 1.0, J2EE 1.4
 public interface SOAPBodyElement extends SOAPElement { } 

SOAPBodyElement is a subinterface of SOAPElement that represents an element that has been added directly to the body of a SOAP message. In all other respects, a SOAPBodyElement is the same as a SOAPElement .

The most direct way to create a SOAPBodyElement is to use the addBodyElement( ) method of SOAPBody , supplying the element name in the form of a Name object:

 SOAPFacctory factory = SOAPFactory.newInstance(); Name elementName = factory.createName("BookSearch", "book",                                        "urn:BookService"); SOAPBodyElement bodyElement = soapBody.addBodyElement(elementName); bodyElement.addTextNode("Java Web Services"); 

Since SOAPBody is itself a SOAPElement , it inherits its addChildElement( ) methods. It is therefore possible to use these methods to directly add elements to a SOAPBody like this:

 SOAPElement element = body.addChildElement(                                           "BookSearch", "book",                                                              "urn:BookService"); 

This code actually creates a SOAPBodyElement rather than an ordinary SOAPElement . Additionally, SOAPElement s created using factory methods and added directly to the SOAP body are replaced by SOAPBodyElement s. Therefore, in the following code extract:

 SOAPElement element = factory.createElement("BookSearch", "book",       "urn:BookService"); SOAPElement textElement = element.addTextNode("J2ME"); SOAPElement bodyElement = body.addChildElement(element); 

the result of the addChildElement( ) method called on the third line is that a new SOAPBodyElement is created and added to the body in place of the original element and a reference to that SOAPBodyElement is returned. Any elements below the original element (in this case, the Text node) are copied and placed below the newly created SOAPBodyElement .

Implementations

SOAPFault

Returned By

SOAPBody.addBodyElement( )


   


Java Web Services in a Nutshell
Java Web Services in a Nutshell
ISBN: 0596003994
EAN: 2147483647
Year: 2003
Pages: 257
Authors: Kim Topley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net