background image

DOM and DOMSource Examples

<< Running Header Example | SOAPBodyElement >>
<< Running Header Example | SOAPBodyElement >>

DOM and DOMSource Examples

env:role=
"http://gizmos.com/orders"/>
<ns:shippingDesk xmlns:ns=
"http://gizmos.com/NSURI"
env:role=
"http://gizmos.com/shipping"/>
<ns:confirmationDesk xmlns:ns=
"http://gizmos.com/NSURI"
env:mustUnderstand=
"true" env:role="http://gizmos.com/confirmations"/>
<ns:billingDesk xmlns:ns=
"http://gizmos.com/NSURI"
env:relay=
"true" env:role="http://gizmos.com/billing"/>
</env:Header><env:Body/></env:Envelope>
Header name is {http://gizmos.com/NSURI}orderDesk
Role is http://gizmos.com/orders
mustUnderstand is false
relay is false
Header name is {http://gizmos.com/NSURI}shippingDesk
Role is http://gizmos.com/shipping
mustUnderstand is false
relay is false
Header name is {http://gizmos.com/NSURI}confirmationDesk
Role is http://gizmos.com/confirmations
mustUnderstand is true
relay is false
Header name is {http://gizmos.com/NSURI}billingDesk
Role is http://gizmos.com/billing
mustUnderstand is false
relay is true
DOM and DOMSource Examples
The examples DOMExample.java and DOMSrcExample.java show how to add a DOM document
to a message and then traverse its contents. They show two ways to do this:
DOMExample.java
creates a DOM document and adds it to the body of a message.
DOMSrcExample.java
creates the document, uses it to create a DOMSource object, and then
sets the DOMSource object as the content of the message's SOAP part.
You will find the code for DOMExample and DOMSrcExample in the following directory:
tut-install/javaeetutorial5/examples/saaj/dom/src/
Examining the DOMExample Class
DOMExample
first creates a DOM document by parsing an XML document. The file it parses is
one that you specify on the command line.
Code Examples
Chapter 19 · SOAP with Attachments API for Java
617