Chapter 8 Using the Sybase Web Services Client Proxy
Using the Client Proxy to access Web services is straightforward. The SoapProxy class that you instantiate to create an object and interface to the Web service is located in the wsclient.jar file. The SoapProxy contains a method called invokeService which your code calls to invoke the Web service. The invokeService method takes the information necessary to identify the service you want and the input values it needs.
When invokeService is called, it takes the name of the Web service and a vector of objects that correspond to the in , out , and inout parameters that make up the Web service's signature. If the Web service being invoked returns a value, the invokeService method returns a value of type java.lang.Object.
Below is an example from the SOAP Sample Application code that illustrates how the invokeService method is called. Some code has been omitted for simplification. The following sections explain in detail how to use the invokeService method.
WARNING! | The following code samples have line breaks to accommodate space limitations. Copying the code to paste for your use might include hidden symbols that are not part of the code. |
//Required import statements import com.sybase.webservices.soap.proxy.SoapProxy; import com.sybase.webservices.util.WebservicesException; import com.sybase.webservices.util.WebservicesConstants; import java.util.Vector; //Instantiate the SoapProxy class, WSDL filename is optional SoapProxy proxy = new SoapProxy( ); //method name string comes from the SOAP action for the service String methodName="SoapDemo/FindDog.findByGender"; //You add the code to create the parameter objects added to //the parameter vector Vector params = new Vector(); //Find all female dogs. String gender= "1"; params.add (gender); try { //Invoke the Web service String[][] rtn = (String[][] ) proxy.invokeService(MethodName, params ); } catch ( Exception e ) {...exception handling omitted }
Copyright © 2002 Sybase, Inc. All rights reserved. |
![]() |