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 Keith Hatton <kh...@axiomsystems.com> on 2003/12/12 12:00:03 UTC

Best practice for Java Object types like Integer, Long, ...

Not an Axis-specific question, more about WSDL and Java...

I have a number of methods with parameters or return types like java.lang.Integer or java.lang.Long.

Using Java2WSDL/WSDL2Java these get converted into int and long, which is not what I need - null is a valid value. But I can't put nillable="true" in the <wsdl:part ... /> sections of my <wsdl:message .../> elements.

How can I work around this? In some cases I have declared dummy types in my WSDL to work around this, like so:

    <simpleType name="searchID">
        <xsd:restriction base="xsd:long" nillable="true"/>
    </simpleType>

But (a) this is rather ugly and (b) I have now hit a further problem where the return type is java.lang.Long.

My Web Service class could wrap these methods and accept/return Strings instead, but of course that loses a lot of type information.

Any ideas appreciated - I would have thought this was an FAQ but a (quick) search didn't reveal anything.

Thanks
Keith

RE: Best practice for Java Object types like Integer, Long, ...

Posted by Rick Kellogg <rm...@comcast.net>.
Keith,

In general, the approach you are taking will not work with other languages.
You see for example, C# does not include a Long data type.  It only includes
long and Object.  I suggest another approach using marker values.

Good luck,
Rick
 

-----Original Message-----
From: Keith Hatton [mailto:khatton@axiomsystems.com] 
Sent: Friday, December 12, 2003 6:00 AM
To: Axis-User (E-mail)
Subject: Best practice for Java Object types like Integer, Long, ...

Not an Axis-specific question, more about WSDL and Java...

I have a number of methods with parameters or return types like
java.lang.Integer or java.lang.Long.

Using Java2WSDL/WSDL2Java these get converted into int and long, which is
not what I need - null is a valid value. But I can't put nillable="true" in
the <wsdl:part ... /> sections of my <wsdl:message .../> elements.

How can I work around this? In some cases I have declared dummy types in my
WSDL to work around this, like so:

    <simpleType name="searchID">
        <xsd:restriction base="xsd:long" nillable="true"/>
    </simpleType>

But (a) this is rather ugly and (b) I have now hit a further problem where
the return type is java.lang.Long.

My Web Service class could wrap these methods and accept/return Strings
instead, but of course that loses a lot of type information.

Any ideas appreciated - I would have thought this was an FAQ but a (quick)
search didn't reveal anything.

Thanks
Keith