Calling Java Proxy Methods

Java services call other services through the Java service proxy interface.

You can generate proxy method invocations using drag-and-drop in the service editor. However, you may need to modify the generated code to supply appropriate input values and handle returned data.

Understanding parameter datatypes

Java datatypes used in the proxy methods are converted from the parameter types used in the WSDL specification of the service interface, with WSDL to Java conversion following the Apache AXIS XML-to-Java mappings. Mappings to standard Java types are provided for the commonly used XML schema types listed in the following table.

Table 1. XML to Java mappings for commonly used datatypes
XML datatype Java datatype
xsd:boolean boolean or, if the parameter is nillable, java.lang.Boolean
xsd:byte byte or, if the parameter is nillable, java.lang.Byte
xsd:double double or, if the parameter is nillable, java.lang.Double
xsd:float float or, if the parameter is nillable, java.lang.Float
xsd:int int or, if the parameter is nillable, java.lang.Integer
xsd:long long or, if the parameter is nillable, java.lang.Long
xsd:short short or, if the parameter is nillable, java.lang.Short
xsd:integer java.math.BigInteger
xsd:string java.lang.String
xsd:decimal java.math.BigDecimal
xsd:dateTime java.util.Calendar
xsd:QName javax.xml.namespace.QName
xsd:base64Binary byte[]
xsd:hexBinary byte[]

Other complex XML schema types convert to Java classes which typically follow the JavaBeans pattern with getter and setter methods for each subelement allowed by the XML schema. Use these resources to review the generated class's public interface:


When you invoke a SOAP service, the proxy for the SOAP service uses Java types derived from the schema types used in the SOAP service WSDL. These generated classes wrap parameter input values and return values using the JavaBeans getter/setter pattern to access the wrapped value. You must write code to create these objects and get and set values. Use the techniques described above to inspect the interface of the wrapper types.

Handling input-output or output parameters

Input-output or output parameters in the WSDL operation are represented by JAX-RPC holder parameters in the proxy method prototype. A holder class implements the javax.xml.rpc.holders.Holder interface and typically has a public value field that contains the value being passed to or returned from the service invocation. The type of the value field matches the corresponding XML parameter type.

Note: Since Java service operations cannot have input-output parameters, Java methods that are exposed as service operations cannot use JAX-RPC holder classes as parameters or return values. Java Service Datatypes describes the types that can be used in the Java service interface.

Example: Calling a database service operation

The example below shows a Java service method process that calls a database service method sp_product_info to invoke a stored procedure of the same name. The proxy for sp_product_info takes as parameters, respectively:


import org.apache.wsif.WSIFException;
import mycompany.IASA_ProdInfo;
import com.sybase.schemas.services.jdbc.V1_1.sp_product_info.holders.*;
import com.sybase.schemas.services.jdbc.V1_1.sp_product_info.*;
import javax.xml.rpc.holders.*;
import com.sybase.stf.annotations.ServiceMethod;
import com.sybase.stf.annotations.Service;
import com.sybase.stf.annotations.Reference;
 
public class Composite {

        /**
         * process
         * @version Thu Jul 28 15:10:18 MDT 2005
         */
        public Sp_product_infoResultSet1Type process(int prodID) {

                IntHolder prod_id = new IntHolder(prodID);
                IntHolder return_value = new IntHolder();
                UpdateCountsTypeHolder update_counts = new UpdateCountsTypeHolder();
                WarningsTypeHolder warnings = new WarningsTypeHolder();
                Sp_product_infoResultSet1TypeHolder sp_product_infoResultSet1 = new Sp_product_infoResultSet1TypeHolder();

                aSA_ProdInfo.sp_product_info(prod_id, return_value, update_counts,
                                warnings, sp_product_infoResultSet1);

                return sp_product_infoResultSet1.value;
        }

        /**
         * Automatically-generated member variable for service invocation. This variable does not require initialization at design-time.
         */
        @Reference
        private IASA_ProdInfo aSA_ProdInfo;
}
Related reference
Java Service Datatypes

Send your feedback on this help topic to Sybase Technical Publications: pubs@sybase.com

Your comments will be sent to the technical publications staff at Sybase, Inc. For product-related issues or technical support, contact Sybase Technical Support at 1-800-8SYBASE.