Client Code
The client code is shown in Example 5-2, later in this section. When invoking the client application, you can specify as many SKUs as you like on the command line. For example, the following command line:
java com.ecerami.soap.PriceListClient A358185 A358565
will generate the following output:
Price List Checker: SOAP Client SKU: A358185 --> 54.99 SKU: A358565 --> 19.99
In examining the client code, first note the
TargetObjectURI
and method name:
call.setTargetObjectURI ("urn:examples:pricelistservice"); call.setMethodName ("getPriceList");
Here, we are assuming that the pricelistservice
has already been deployed via the web administrator tool.
Alternatively, you could use the command-line tool and the following
deployment descriptor:
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:examples:pricelistservice" checkMustUnderstands="false"> <isd:provider type="java" scope="Request" methods="getPriceList"> <isd:java class="com.ecerami.soap.PriceListService" static="false"/> </isd:provider> </isd:service>
To pass an array from client to server, you must create a new
Parameter
object. The important distinction is
that you must specify an array class, such as
String[].class
or
Double[].class
, to the
Parameter
constructor. For example, our new client
creates an array parameter of string SKUs:
Parameter param = new Parameter("sku", String[].class, skus, Constants.NS_URI_SOAP_ENC);
The array parameter is then added to a Vector
of
parameters, and the Vector ...
Get Web Services Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.