This will connect to the provided URL
and attempt
to use the cd-catalog-demo web service to add a new
{@link CD}
, using the supplied information about
the CD.
System.out.println("Adding CD titled '" + title + "' by '" +
artist + "', on the label " + label);
CD cd = new CD(title, artist, label);
// Map this type so SOAP can use it
SOAPMappingRegistry registry = new SOAPMappingRegistry();
BeanSerializer serializer = new BeanSerializer();
registry.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("urn:cd-catalog-demo", "cd"),
CD.class, serializer, serializer);
// Build the Call object
Call call = new Call();
call.setSOAPMappingRegistry(registry);
call.setTargetObjectURI("urn:cd-catalog");
call.setMethodName("addCD");
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// Set up parameters
Vector params = new Vector();
params.addElement(new Parameter("cd", CD.class, cd, null));
call.setParams(params);
// Invoke the call
Response response;
response = call.invoke(url, "");
if (!response.generatedFault()) {
System.out.println("Successful CD Addition.");
} else {
Fault fault = response.getFault();
System.out.println("Error encountered: " + fault.getFaultString());
Vector entries = fault.getDetailEntries();
for (Iterator i = entries.iterator(); i.hasNext(); ) {
org.w3c.dom.Element entry = (org.w3c.dom.Element)i.next();
System.out.println(entry.getFirstChild().getNodeValue());
}
}