When you run DOMExample and DOMSrcExample, you can specify one of two sample XML files in the directory tut-install/javaeetutorial5/examples/saaj/dom/:
slide.xml, a file that consists only of a message body
domsrc.xml, an example that has a SOAP header (the contents of the HeaderExample SOAP 1.1 output) and the same message body as slide.xml
You can use either of these files when you run DOMExample. You can use domsrc.xml to run DOMSrcExample.
To build the programs using NetBeans IDE, follow these steps:
In NetBeans IDE, choose Open Project from the File menu.
In the Open Project dialog, navigate to tut-install/javaeetutorial5/examples/saaj/.
Select the dom folder.
Select the Open as Main Project check box.
Click Open Project.
A Reference Problems dialog appears. Click Close.
Right-click the dom project and choose Resolve Reference Problems.
In the Resolve Reference Problems dialog, select the first of the missing JAR files and click Resolve.
The missing files are activation.jar, javaee.jar, and appserv-ws.jar.
Navigate to the as-install/lib/ directory.
Select the missing JAR file (activation.jar, for example) and click Open.
In the Resolve Reference Problems dialog, all the files have green check marks to the left of their names.
Click Close.
Right-click the project and choose Build.
To run DOMExample using NetBeans IDE, follow these steps:
Right-click the dom project and choose Properties.
Select Run from the Categories tree.
Click Browse next to the Main Class field.
In the Browse Main Classes dialog, select DomExample.
Click Select Main Class.
In the Arguments field, type the following:
slide.xml |
Click OK.
Right-click the project and choose Run.
To run DOMSrcExample using NetBeans IDE, follow these steps:
Right-click the dom project and choose Properties.
Select Run from the Categories tree.
Click Browse next to the Main Class field.
In the Browse Main Classes dialog, select DomSrcExample.
Click Select Main Class.
In the Arguments field, type the following:
domsrc.xml |
Click OK.
Right-click the project and choose Run.
To run the examples using Ant, go to the directory tut-install/javaeetutorial5/examples/saaj/dom/.
To run DOMExample using Ant, use the following command:
ant run-dom -Dxml-file=slide.xml |
To run DOMSrcExample using Ant, use the following command:
ant run-domsrc -Dxml-file=domsrc.xml |
When you run DOMExample using the file slide.xml, you will see output that begins like the following:
Running DOMExample. Name is slideshow Attribute name is author Attribute value is Yours Truly Attribute name is date Attribute value is Date of publication Attribute name is title Attribute value is Sample Slide Show Content is: ... |
When you run DOMSrcExample using the file domsrc.xml, you will see output that begins like the following:
Running DOMSrcExample. Header contents: Content is: Name is {http://gizmos.com/NSURI}orderDesk Attribute name is SOAP-ENV:actor Attribute value is http://gizmos.com/orders Content is: ... |
If you run DOMSrcExample with the file slide.xml, you will see runtime errors.