Chapter 8 Using the Sybase Web Services Client Proxy
When you have found the SOAPAction for your Web service, you can use it to determine how to fill the parameter vector for the SoapProxy invokeService() method. Following the Web service method name is the return value, if any, and an ordered list of method parameters. Each parameter is noted as an in , out or inout parameter. For each parameter in the method signature, you must supply an object of the same type, in the same order. For in parameters, the supplied object contains the value the Web service needs.
When you look at the SoapSampleImpl.wsdl file and the findByGender Web service, you see that one in parameter is required. This parameter is the gender value expressed as a string. In the SOAP Sample code, a String variable is created and set to the proper value. The variable is then added to the vector, as shown:
Vector params = new Vector(); String gender = "0"; params.add( gender );
Because vector only takes objects-float, int and long are primitive types-they need to be wrapped in their object types. You need to add types to the vector in the same order as your parameters.
The following example uses several different datatypes. The SOAPAction indicates an int return value, an in value of type double, and an out parameter of type DoubleHolder. The SOAPAction for this example is:
soapAction= "WebservicesTestPackage/MyDblArrayCmpnt.getIntNDouble return,int,return in,double,p0 out,org.omg. DoubleHolder,p1"
The following example creates a valid parameters vector for the invokeService method:
//...some import statements omitted import org.omg.CORBA.DoubleHolder;
//...omitted code for creating the methodName
Vector params = new Vector();
//create the double in parameter and wrapper it with the //Double class so it can be added to the parameter //vector. double d = 6.02e+23d; Double dbl = new Double(d); params.add( dbl );
//creating the out parameter object and add it to the //parameter vector DoubleHolder dblHolder = new DoubleHolder(); params.add( dblHolder );
For all parameters of primitive types, the corresponding
wrapper object must be used.
Copyright © 2002 Sybase, Inc. All rights reserved. |
![]() |