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 Dan Washusen <da...@gmail.com> on 2006/05/24 06:09:14 UTC
AntCodegenTask mapping xsd:long to java primitive long?
Hi All,
I'm attempting to run the Axis2 AntCodegenTask ant task to generate my
Objects based on a schema. The element in question is specified as:
<xsd:complexType name="ClientDetailsType">
> <xsd:sequence>
> <xsd:element name="cmtAccount1Id" type="xsd:long" nillable="true" />
> </xsd:sequence>
> </xsd:complexType>
>
When I run the ant task the ClientDetailsType class is generated with the
cmtAccount1Id attribute as a primitive long and throws a
NumberFormatException when I try and invoke the web service and the
cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
the BigInteger java type is used and it works...
Am I missing something? Why is the primitive long being used if the element
is specified as nillable?
Cheers,
Dan
Re: AntCodegenTask mapping xsd:long to java primitive long?
Posted by Dan Washusen <da...@gmail.com>.
Ok, now I'm confisued (or maybe I wasn't cleear enough)...
My XSD looks like (missing a few bits):
> <xsd:complexType name="ClientDetailsType">
> <xsd:sequence>
> <xsd:element name="partyId" type="xsd:long"/>
> <xsd:element name="externalId" type="xsd:string"/>
> <xsd:element name="description" type="xsd:string" nillable="true"
> minOccurs="0"/>
> <xsd:element name="company" type="xsd:string" nillable="true"
> minOccurs="0"/>
> <xsd:element name="abnacn" type="xsd:string" nillable="true"
> minOccurs="0"/>
> <xsd:element name="cmtAccount1Id" type="xsd:integer" nillable="true"
> minOccurs="0" />
> <xsd:element name="cmtAccount2Id" type="xsd:integer" nillable="true"
> minOccurs="0" />
> <xsd:element name="lastStatement" type="xsd:date" nillable="true"
> minOccurs="0"/>
> <xsd:element name="status" type="status" nillable="true"
> minOccurs="0"/>
> </xsd:sequence>
> </xsd:complexType>
And the resulting XML from the web service call looks like:
> <RetrieveClientDetailsProcessResponse xmlns="
> http://www.nxf.com.au/RetrieveClientDetails">
> <StatusMsg>
> <Status xmlns="http://www.nxf.com.au/NXFMessageTypes">0</Status>
> <StatusDetailedMsg xmlns="http://www.nxf.com.au/NXFMessageTypes"/>
> </StatusMsg>
> <ClientDetails xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance
> ">
> <ns1:partyId xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes
> ">13</ns1:partyId>
> <ns1:externalId xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes
> ">OPTEST1</ns1:externalId>
> <ns1:description xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes">Client
> 1</ns1:description>
> <ns1:company xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes"
> xsi:nil="true"/>
> <ns1:abnacn xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes"
> xsi:nil="true"/>
> <ns1:cmtAccount1Id xmlns:ns1="
> http://www.nxf.com.au/NXFMessageTypes" xsi:nil="true"/>
> <ns1:cmtAccount2Id xmlns:ns1="
> http://www.nxf.com.au/NXFMessageTypes" xsi:nil="true"/>
> <ns1:lastStatement xmlns:ns1="
> http://www.nxf.com.au/NXFMessageTypes" xsi:nil="true"/>
> <ns1:status xmlns:ns1="http://www.nxf.com.au/NXFMessageTypes
> ">ACTIVE</ns1:status>
> </ClientDetails>
> </RetrieveClientDetailsProcessResponse>
When Axis2 tries to parse the cmtAccount1Id it throws the following error
(seemingly ignoring the xsi:nil marker???):
>
> java.lang.NumberFormatException: Zero length BigInteger
> java.lang.RuntimeException: java.lang.NumberFormatException: Zero length
> BigInteger
> at org.apache.axis2.RetrieveClientDetailsStub.fromOM(
> RetrieveClientDetailsStub.java:355)
> at org.apache.axis2.RetrieveClientDetailsStub.process(
> RetrieveClientDetailsStub.java:114)
> at org.apache.axis2.RetrieveClientDetailsTest.testprocess(
> RetrieveClientDetailsTest.java:24)
>
To summerise, I would have thaught marking an element with xsi:nil="true"
would make axis ignore the element (not try and parse it)...
Any ideas?
Cheers,
Dan
On 5/25/06, robert lazarski <ro...@gmail.com> wrote:
>
> Isn't it Nillable == false to switch the primitive to an Object?
>
>
> <xsd:element name="myInteger" type="xsd:int" nillable="false" />
>
> HTH,
> Robert
> http://www.braziloutsource.com/
>
>
>
> On 5/24/06, Dan Washusen <da...@gmail.com> wrote:
> >
> > Actually, changing it to xsd:integer doesn't work... it seems like axis
> > is ignoring the xsi:nil?
> >
> >
> > On 5/24/06, Dan Washusen < dan.washusen@gmail.com> wrote:
> > >
> > > Hi All,
> > > I'm attempting to run the Axis2 AntCodegenTask ant task to generate my
> > > Objects based on a schema. The element in question is specified as:
> > >
> > > <xsd:complexType name="ClientDetailsType">
> > > > <xsd:sequence>
> > > > <xsd:element name="cmtAccount1Id" type="xsd:long"
> > > > nillable="true" />
> > > > </xsd:sequence>
> > > > </xsd:complexType>
> > > >
> > >
> > > When I run the ant task the ClientDetailsType class is generated with
> > > the cmtAccount1Id attribute as a primitive long and throws a
> > > NumberFormatException when I try and invoke the web service and the
> > > cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
> > > the BigInteger java type is used and it works...
> > >
> > > Am I missing something? Why is the primitive long being used if the
> > > element is specified as nillable?
> > >
> > > Cheers,
> > > Dan
> > >
> >
> >
>
Re: AntCodegenTask mapping xsd:long to java primitive long?
Posted by Dan Washusen <da...@gmail.com>.
Your suggestion helped although probably not in the way you expected... I
switched to xmlbeans and it's working as expected...
On 5/25/06, robert lazarski <ro...@gmail.com> wrote:
>
> OK, now I remember, the default is Integer:
>
> <element minOccurs="1" maxOccurs="1" name="QuantidadeItemConsumido"
> type="xsd:int"/>
>
> On both the client and the service that maps to Integer for me using
> xmlbeans. Although that might be a java 5.0 feature. And nillable == false
> is to get an int instead of Integer.
>
> Sorry if that doesn't help, I remebered wrong on my last post.
>
>
> Robert
> http://www.braziloutsource.com/
>
> On 5/24/06, robert lazarski <robertlazarski@gmail.com > wrote:
> >
> > Isn't it Nillable == false to switch the primitive to an Object?
> >
> >
> > <xsd:element name="myInteger" type="xsd:int" nillable="false" />
> >
> > HTH,
> > Robert
> > http://www.braziloutsource.com/
> >
> >
> >
> > On 5/24/06, Dan Washusen <dan.washusen@gmail.com > wrote:
> > >
> > > Actually, changing it to xsd:integer doesn't work... it seems like
> > > axis is ignoring the xsi:nil?
> > >
> > >
> > > On 5/24/06, Dan Washusen < dan.washusen@gmail.com> wrote:
> > > >
> > > > Hi All,
> > > > I'm attempting to run the Axis2 AntCodegenTask ant task to generate
> > > > my Objects based on a schema. The element in question is specified as:
> > > >
> > > > <xsd:complexType name="ClientDetailsType">
> > > > > <xsd:sequence>
> > > > > <xsd:element name="cmtAccount1Id" type="xsd:long"
> > > > > nillable="true" />
> > > > > </xsd:sequence>
> > > > > </xsd:complexType>
> > > > >
> > > >
> > > > When I run the ant task the ClientDetailsType class is generated
> > > > with the cmtAccount1Id attribute as a primitive long and throws a
> > > > NumberFormatException when I try and invoke the web service and the
> > > > cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
> > > > the BigInteger java type is used and it works...
> > > >
> > > > Am I missing something? Why is the primitive long being used if the
> > > > element is specified as nillable?
> > > >
> > > > Cheers,
> > > > Dan
> > > >
> > >
> > >
> >
>
Re: AntCodegenTask mapping xsd:long to java primitive long?
Posted by robert lazarski <ro...@gmail.com>.
OK, now I remember, the default is Integer:
<element minOccurs="1" maxOccurs="1" name="QuantidadeItemConsumido"
type="xsd:int"/>
On both the client and the service that maps to Integer for me using
xmlbeans. Although that might be a java 5.0 feature. And nillable == false
is to get an int instead of Integer.
Sorry if that doesn't help, I remebered wrong on my last post.
Robert
http://www.braziloutsource.com/
On 5/24/06, robert lazarski <ro...@gmail.com> wrote:
>
> Isn't it Nillable == false to switch the primitive to an Object?
>
>
> <xsd:element name="myInteger" type="xsd:int" nillable="false" />
>
> HTH,
> Robert
> http://www.braziloutsource.com/
>
>
>
> On 5/24/06, Dan Washusen <dan.washusen@gmail.com > wrote:
> >
> > Actually, changing it to xsd:integer doesn't work... it seems like axis
> > is ignoring the xsi:nil?
> >
> >
> > On 5/24/06, Dan Washusen < dan.washusen@gmail.com> wrote:
> > >
> > > Hi All,
> > > I'm attempting to run the Axis2 AntCodegenTask ant task to generate my
> > > Objects based on a schema. The element in question is specified as:
> > >
> > > <xsd:complexType name="ClientDetailsType">
> > > > <xsd:sequence>
> > > > <xsd:element name="cmtAccount1Id" type="xsd:long"
> > > > nillable="true" />
> > > > </xsd:sequence>
> > > > </xsd:complexType>
> > > >
> > >
> > > When I run the ant task the ClientDetailsType class is generated with
> > > the cmtAccount1Id attribute as a primitive long and throws a
> > > NumberFormatException when I try and invoke the web service and the
> > > cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
> > > the BigInteger java type is used and it works...
> > >
> > > Am I missing something? Why is the primitive long being used if the
> > > element is specified as nillable?
> > >
> > > Cheers,
> > > Dan
> > >
> >
> >
>
Re: AntCodegenTask mapping xsd:long to java primitive long?
Posted by robert lazarski <ro...@gmail.com>.
Isn't it Nillable == false to switch the primitive to an Object?
<xsd:element name="myInteger" type="xsd:int" nillable="false" />
HTH,
Robert
http://www.braziloutsource.com/
On 5/24/06, Dan Washusen <da...@gmail.com> wrote:
>
> Actually, changing it to xsd:integer doesn't work... it seems like axis is
> ignoring the xsi:nil?
>
>
> On 5/24/06, Dan Washusen < dan.washusen@gmail.com> wrote:
> >
> > Hi All,
> > I'm attempting to run the Axis2 AntCodegenTask ant task to generate my
> > Objects based on a schema. The element in question is specified as:
> >
> > <xsd:complexType name="ClientDetailsType">
> > > <xsd:sequence>
> > > <xsd:element name="cmtAccount1Id" type="xsd:long"
> > > nillable="true" />
> > > </xsd:sequence>
> > > </xsd:complexType>
> > >
> >
> > When I run the ant task the ClientDetailsType class is generated with
> > the cmtAccount1Id attribute as a primitive long and throws a
> > NumberFormatException when I try and invoke the web service and the
> > cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
> > the BigInteger java type is used and it works...
> >
> > Am I missing something? Why is the primitive long being used if the
> > element is specified as nillable?
> >
> > Cheers,
> > Dan
> >
>
>
Re: AntCodegenTask mapping xsd:long to java primitive long?
Posted by Dan Washusen <da...@gmail.com>.
Actually, changing it to xsd:integer doesn't work... it seems like axis is
ignoring the xsi:nil?
On 5/24/06, Dan Washusen <da...@gmail.com> wrote:
>
> Hi All,
> I'm attempting to run the Axis2 AntCodegenTask ant task to generate my
> Objects based on a schema. The element in question is specified as:
>
> <xsd:complexType name="ClientDetailsType">
> > <xsd:sequence>
> > <xsd:element name="cmtAccount1Id" type="xsd:long" nillable="true"
> > />
> > </xsd:sequence>
> > </xsd:complexType>
> >
>
> When I run the ant task the ClientDetailsType class is generated with the
> cmtAccount1Id attribute as a primitive long and throws a
> NumberFormatException when I try and invoke the web service and the
> cmtAccount1Id is nil. If I change the type from "xsd:long" to "xsd:integer"
> the BigInteger java type is used and it works...
>
> Am I missing something? Why is the primitive long being used if the
> element is specified as nillable?
>
> Cheers,
> Dan
>