You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Fabio Benedetti <fa...@it.ibm.com> on 2002/09/03 17:47:21 UTC

Problem with methods returning java.lang.Object

Hello all,

I have done a very simple test creating a java class with a method like:

Object returnObj() {
     return new Long(10);
}

Wrapping it in an axis web service I got some strange results (I am using
axis-beta3).

The returned java.lang.Long is encoded from the server side in a XSD long
element, but the client code fails to convert it into an Object throwing
the following exception:

org.xml.sax.SAXException: Bad types (long -> class java.lang.Object)
        at
org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:236)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:861)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va(Compiled Code))
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:664)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:250)
        at
org.apache.axis.message.RPCElement.getParams(RPCElement.java:274)
........

Doing some debugging I have found that the default Type mapping for an XSD
long is to Java primitive type long and that the conversion routines
between Java types do not handle the case of converting the primitive long
to a wrapper java.lanag.Long and then to a java.lang.Object. Actually looks
like that into JavaUtils.isConvertible and JavaUtils.convert there is some
code to handle conversion from primitive types to their wrapper classes but
it doesn't handle the fact that a wrapper class is compatible with a
java.lang.Object.

Is this a bug or I am missing something?

Fabio
Fabio Benedetti
Job Scheduling Development.
Via Sciangai, 53 00144 Rome
Phone: +39 06596 62433 Fax: +39 06596 62077


Re: Problem with methods returning java.lang.Object

Posted by Steve Loughran <st...@iseran.com>.
----- Original Message -----
From: "Fabio Benedetti" <fa...@it.ibm.com>
To: <ax...@xml.apache.org>
Sent: Tuesday, September 03, 2002 8:47 AM
Subject: Problem with methods returning java.lang.Object


> Hello all,
>
> I have done a very simple test creating a java class with a method like:
>
> Object returnObj() {
>      return new Long(10);
> }
>

ignoring your problems. which may or may not be a bug, what are your
expectations regarding things like VB.NET or Perl working with this
endpoint?