getPrice Method
Parameter skuParam;
// Create SOAP RPC Call Object
Call call = new Call ();
// Set Encoding Style to standard SOAP encoding
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
// Set Object URI and Method Name
call.setTargetObjectURI ("urn:examples:priceservice");
call.setMethodName ("getPrice");
// Set Method Parameters
Vector paramList = new Vector ();
skuParam = new Parameter("sku", String.class,
sku, Constants.NS_URI_SOAP_ENC);
paramList.addElement (skuParam);
call.setParams (paramList);
// Set the URL for the Web Service
URL url = new URL ("http://localhost:8080/soap/servlet/rpcrouter");
// Invoke the Service
Response resp = call.invoke (url, "");
// Check for Success
// Note that a Fault will not trigger a SOAPException
if (!resp.generatedFault()) {
// Extract Return value
Parameter result = resp.getReturnValue ();
Double price = (Double) result.getValue();
return price.doubleValue();
}
// Check for Faults
else {
// Extract Fault Code and throw new Exception
Fault fault = resp.getFault();
String faultString = fault.getFaultString();
throw new ProductNotFoundException (faultString, fault);
}