Return-Path: Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 50078 invoked by uid 500); 16 May 2003 22:52:41 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 50066 invoked from network); 16 May 2003 22:52:41 -0000 Message-ID: <008401c31bfd$e1cefb20$122aa8c0@FourDirections> From: "Edward Wertz" To: Cc: "Edward Wertz" References: <000a01c31ba2$4593c570$a701a8c0@Iastablet> Subject: Fatal Bug in Call.java JavaUtils.convert(long, long[]) fails Date: Fri, 16 May 2003 18:52:21 -0400 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0081_01C31BDC.484F0880" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0081_01C31BDC.484F0880 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable JDK 1.4 and up. Used last nights build of Axis.=20 The scenerio is that I'm using a Doc-Literal webservice. In the return = message I'm expecting back a long[]. The problem comes in when the = message has a single item in the array. When the message has an array = of length > 1 the JavaUtils.convert is invoked to convert from an = ArrayList to long[]. When there is a single long in the message the = JavaUtils.convert is invoked to convert from long to long[]. The = conversion is not happening from long to long[]. I followed the axis = code in my debugger and nowhere else is the long converted to a long[]. = My wsdl2java generated stub code is expecting a long[] from the = call.invoke, but it is getting a long back because it was not put inside = of an array. This causes a cast exception to occur. It looks like the problem is that JavaUtils.convert doesn't make arrays = out of single values. Tracing the convert function returns in a section = of code saying there was no mapping between the two types. =20 This is the comment on the JavaUtils.convert function: /** Utility function to convert an Object to some desired Class. * * Right now this works for: * arrays <-> Lists, * Holders <-> held values * @param arg the array to convert * @param destClass the actual class we want */ This is the section of code that causes the convert function to return.=20 // Return if no conversion is available if (!(arg instanceof Collection || (arg !=3D null && arg.getClass().isArray())) && ((destHeldType =3D=3D null && argHeldType =3D=3D null) || (destHeldType !=3D null && argHeldType !=3D null))) { return arg; } The Axis Code: Call.java Line 2303=20 /** Invoke an RPC service with a pre-constructed RPCElement. * * Note: Not part of JAX-RPC specification. * * @param body an RPCElement containing all the information about * this call. * @return a deserialized Java Object containing the return value * @exception AxisFault */ public Object invoke( RPCElement body ) throws AxisFault { . . . // The following loop looks at the resargs and // converts the value to the appropriate return/out = parameter // value. If the return value is found, is value is // placed in result. The remaining resargs are // placed in the outParams list (note that if a resArg // is found that does not match a operation parameter = qname, // it is still placed in the outParms list). for (int i =3D outParamStart; i < resArgs.size(); i++) { RPCParam param =3D (RPCParam) resArgs.get(i); Class javaType =3D = getJavaTypeForQName(param.getQName()); Object value =3D param.getValue(); // Convert type if needed if (javaType !=3D null && value !=3D null && !javaType.isAssignableFrom(value.getClass())) = { --------> value =3D JavaUtils.convert(value, javaType); } . . . Line 2365=20 // Convert type if needed if (operation !=3D null && operation.getReturnClass() !=3D null) = { --------> result =3D JavaUtils.convert(result, = operation.getReturnClass()); =20 } =20 return( result ); } ------=_NextPart_000_0081_01C31BDC.484F0880 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
JDK 1.4 and up.
Used last nights build of Axis. =
 
The scenerio is that I'm using a = Doc-Literal=20 webservice.  In the return message I'm expecting back a = long[].  The=20 problem comes in when the message has a single item in the array.  = When the=20 message has an array of length > 1 the JavaUtils.convert is invoked = to=20 convert from an ArrayList to long[].  When there is a single long = in the=20 message the JavaUtils.convert is invoked to convert from long to = long[]. =20 The conversion is not happening from long to long[].  I followed = the axis=20 code in my debugger and nowhere else is the long converted to a=20 long[].   My wsdl2java generated stub code is expecting a = long[]=20 from the call.invoke, but it is getting a long back because it was not = put=20 inside of an array.  This causes a cast exception to = occur.
 
It looks like the problem is that = JavaUtils.convert=20 doesn't make arrays out of single values.  Tracing the convert=20 function returns in a section of code saying there was no mapping = between=20 the two types. 
 
This is the comment on the = JavaUtils.convert=20 function:

    /** Utility function to convert an Object to = some=20 desired Class.
     *
     = * Right=20 now this works for:
     = *     arrays=20 <-> Lists,
     *     = Holders=20 <-> held values
     * @param arg the array = to=20 convert
     * @param destClass the actual class = we=20 want
     */
 
This is the section of code that causes the convert function to = return.=20

        // Return if no = conversion=20 is available
        if (!(arg = instanceof=20 Collection=20 ||
           &= nbsp; =20 (arg !=3D null && arg.getClass().isArray()))=20 &&
          = ; =20 ((destHeldType =3D=3D null && argHeldType =3D=3D null)=20 ||
           &= nbsp;=20 (destHeldType !=3D null && argHeldType !=3D null)))=20 {
            = return=20 arg;
        }
 
 
 
The Axis Code: Call.java Line 2303 
 

    /** Invoke an RPC service with a = pre-constructed=20 RPCElement.
     *
     * = Note:=20 Not part of JAX-RPC specification.
    =20 *
     * @param body an RPCElement containing all = the=20 information about
    =20 *            = this=20 call.
     * @return a deserialized Java Object=20 containing the return value
     * @exception=20 AxisFault
     */
    public = Object=20 invoke( RPCElement body ) throws AxisFault {
 
    .
    .
    .
           &n= bsp;   =20 // The following loop looks at the resargs=20 and
           =     =20 // converts the value to the appropriate return/out=20 parameter
          =      =20 // value.  If the return value is found, is value=20 is
           &= nbsp;   =20 // placed in result.  The remaining resargs=20 are
           =     =20 // placed in the outParams list (note that if a=20 resArg
          &nb= sp;    =20 // is found that does not match a operation parameter=20 qname,
          &nb= sp;    =20 // it is still placed in the outParms=20 list).
          &nb= sp;    =20 for (int i =3D outParamStart; i < resArgs.size(); i++)=20 {
           &n= bsp;       =20 RPCParam param =3D (RPCParam) resArgs.get(i);
 
           &n= bsp;       =20 Class javaType =3D=20 getJavaTypeForQName(param.getQName());
     &= nbsp;           &n= bsp; =20 Object value =3D param.getValue();
 
           &n= bsp;       =20 // Convert type if=20 needed
          &nb= sp;        =20 if (javaType !=3D null && value !=3D null=20 &&
          = ;            =     =20 !javaType.isAssignableFrom(value.getClass())) {
-------->=20             &= nbsp;  =20 value =3D JavaUtils.convert(value,=20 javaType);
          = ;         =20 }
    .
    .
    .
 
Line 2365 
        // = Convert=20 type if needed
        if = (operation !=3D=20 null && operation.getReturnClass() !=3D null)=20 {
-------->   result =3D JavaUtils.convert(result,=20 operation.getReturnClass()); =20
        }
 
        return( result = );
    }
------=_NextPart_000_0081_01C31BDC.484F0880--