Java Reference
In-Depth Information
5. When creating the Dispatch , indicate Payload mode and use Source.class as the data
type.
6. Read in the data you want to specify in the request as the child of the soap:body .
7. Call the invoke method of your Dispatch . Because your Dispatch is parameterized on
Source , that is what you'll get back in response.
8. There isn't much you can do with a Source directly, so transform the result into a DOM
tree you can work with.
9. Use the XPath API to extract the data you're interested in.
You're using the same method on the server side. Example 5-6 shows the complete client list-
ing.
Example5-6.WebserviceclientusingDispatch<Source>withanXMLstringinpayload
mode
public void dispatchPayloadIsbnTest() {
try {
URL wsdl =
new URL("http://localhost:8080/CatalogService/
Catalog?wsdl");
String ns = "http://ns.soacookbook.com/ws/catalog";
String objNs = "http://ns.soacookbook.com/catalog";
//Create the Service name
String svcName = "CatalogService";
QName svcQName = new QName(ns, svcName);
//Get a delegate wrapper
Service service = Service.create(wsdl, svcQName);
//Create the Port name
String portName = "CatalogPort";
QName portQName = new QName(ns, portName);
//Create the dispatcher on Source with Payload
Dispatch<Source> dispatch =
service.createDispatch(portQName,
Source.class, Service.Mode.PAYLOAD);
//Change to tick marks or escape double quotes
String payload =
"<i:isbn xmlns:i='http://ns.soacookbook.com/
Search WWH ::




Custom Search