To build the program 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 headers folder.
Select the Open as Main Project check box.
Click Open Project.
A Reference Problems dialog appears. Click Close.
Right-click the headers 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 the program using NetBeans IDE, follow these steps:
Right-click the headers project and choose Properties.
Select Run from the Categories tree.
In the Arguments field, type the following:
1.1 |
This argument specifies the version of SOAP to be used in generating the message.
Click OK.
Right-click the project and choose Run.
Right-click the project and choose Properties.
Select Run from the Categories tree.
In the Arguments field, type the following:
1.2 |
Click OK.
Right-click the project and choose Run.
To build and run HeaderExample using Ant, go to the directory tut-install/javaeetutorial5/examples/saaj/headers/. Use one of the following commands:
ant run-headers -Dsoap=1.1 |
ant run-headers -Dsoap=1.2 |
When you run HeaderExample to generate a SOAP 1.1 message, you will see output similar to the following:
----- Request Message ---- <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header> <ns:orderDesk xmlns:ns="http://gizmos.com/NSURI" SOAP-ENV:actor="http://gizmos.com/orders"/> <ns:shippingDesk xmlns:ns="http://gizmos.com/NSURI" SOAP-ENV:actor="http://gizmos.com/shipping"/> <ns:confirmationDesk xmlns:ns="http://gizmos.com/NSURI" SOAP-ENV:actor="http://gizmos.com/confirmations" SOAP-ENV:mustUnderstand="1"/> <ns:billingDesk xmlns:ns="http://gizmos.com/NSURI" SOAP-ENV:actor="http://gizmos.com/billing"/> </SOAP-ENV:Header><SOAP-ENV:Body/></SOAP-ENV:Envelope> Header name is {http://gizmos.com/NSURI}orderDesk Actor is http://gizmos.com/orders mustUnderstand is false Header name is {http://gizmos.com/NSURI}shippingDesk Actor is http://gizmos.com/shipping mustUnderstand is false Header name is {http://gizmos.com/NSURI}confirmationDesk Actor is http://gizmos.com/confirmations mustUnderstand is true Header name is {http://gizmos.com/NSURI}billingDesk Actor is http://gizmos.com/billing mustUnderstand is false |
When you run HeaderExample to generate a SOAP 1.2 message, you will see output similar to the following:
----- Request Message ---- <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <ns:orderDesk xmlns:ns="http://gizmos.com/NSURI" 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 |