You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Maharajapuram Ramchandran <me...@gmail.com> on 2010/05/20 19:45:32 UTC

wsdl2java data type mapping discrepancy

Hello,

We are using CXF 2.2.2 to write a webservice and I'm running into this
issue:

I have 2 operations in the service and for a particular node this is what I
have in the XSD. As you can see, the only difference that I have is that the
ID is an optional element in the second operation.

*Operation1:*

<xs:element name="ID" type="ID1"/>

<xs:simpleType name="ID1">

<xs:restriction base="xs:int">

<xs:pattern value="[0-9]{9}"/>

</xs:restriction>


*Operation2*

<xs:element name="ID" type="ID1" minOccurs="0"/>

<xs:simpleType name="ID1">

<xs:restriction base="xs:int">

<xs:pattern value="[0-9]{9}"/>

</xs:restriction>

</xs:simpleType>



When we generate the stubs using wsdl2java, the first one is getting
generated as


protected int ID;

and the second one is

protected Integer requestorID;

I did go through the Aegis default mapping details (
http://cxf.apache.org/docs/aegis-theory-of-operation.html) and it says that
xs:int can be mapped to int or Integer, but I'm curious to know why is this
behaving differently. Is there a reason behind this or it is just random? If
not, Is there a way to get this generated as an Integer. Or should we change
the code manually? Is it a good practice to do that?

Would like to know if someone has faced this discrepancy before! Thanks..

Re: wsdl2java data type mapping discrepancy

Posted by Maharajapuram Ramchandran <me...@gmail.com>.
Glen,

Thanks for the reply.

That was the first thing that I thought of and so I went ahead and changed
both of them. It still gave me the same int and Integer. So I don't think
that is the problem.


On Thu, May 20, 2010 at 7:17 PM, Glen Mazza <gl...@gmail.com> wrote:

>
> I think the reason is that optional elements need to be an Integer instead
> of
> just an int because the former lets you specify that no value was provided
> (you can set an Integer to null but not an int).
>
> Glen
>
>
> Maharajapuram Ramchandran wrote:
> >
> > Hello,
> >
> > We are using CXF 2.2.2 to write a webservice and I'm running into this
> > issue:
> >
> > I have 2 operations in the service and for a particular node this is what
> > I
> > have in the XSD. As you can see, the only difference that I have is that
> > the
> > ID is an optional element in the second operation.
> >
> > *Operation1:*
> >
> > <xs:element name="ID" type="ID1"/>
> >
> > <xs:simpleType name="ID1">
> >
> > <xs:restriction base="xs:int">
> >
> > <xs:pattern value="[0-9]{9}"/>
> >
> > </xs:restriction>
> >
> >
> > *Operation2*
> >
> > <xs:element name="ID" type="ID1" minOccurs="0"/>
> >
> > <xs:simpleType name="ID1">
> >
> > <xs:restriction base="xs:int">
> >
> > <xs:pattern value="[0-9]{9}"/>
> >
> > </xs:restriction>
> >
> > </xs:simpleType>
> >
> >
> >
> > When we generate the stubs using wsdl2java, the first one is getting
> > generated as
> >
> >
> > protected int ID;
> >
> > and the second one is
> >
> > protected Integer requestorID;
> >
> > I did go through the Aegis default mapping details (
> > http://cxf.apache.org/docs/aegis-theory-of-operation.html) and it says
> > that
> > xs:int can be mapped to int or Integer, but I'm curious to know why is
> > this
> > behaving differently. Is there a reason behind this or it is just random?
> > If
> > not, Is there a way to get this generated as an Integer. Or should we
> > change
> > the code manually? Is it a good practice to do that?
> >
> > Would like to know if someone has faced this discrepancy before! Thanks..
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/wsdl2java-data-type-mapping-discrepancy-tp28624667p28628084.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>
>

Re: wsdl2java data type mapping discrepancy

Posted by Glen Mazza <gl...@gmail.com>.
I think the reason is that optional elements need to be an Integer instead of
just an int because the former lets you specify that no value was provided
(you can set an Integer to null but not an int).

Glen


Maharajapuram Ramchandran wrote:
> 
> Hello,
> 
> We are using CXF 2.2.2 to write a webservice and I'm running into this
> issue:
> 
> I have 2 operations in the service and for a particular node this is what
> I
> have in the XSD. As you can see, the only difference that I have is that
> the
> ID is an optional element in the second operation.
> 
> *Operation1:*
> 
> <xs:element name="ID" type="ID1"/>
> 
> <xs:simpleType name="ID1">
> 
> <xs:restriction base="xs:int">
> 
> <xs:pattern value="[0-9]{9}"/>
> 
> </xs:restriction>
> 
> 
> *Operation2*
> 
> <xs:element name="ID" type="ID1" minOccurs="0"/>
> 
> <xs:simpleType name="ID1">
> 
> <xs:restriction base="xs:int">
> 
> <xs:pattern value="[0-9]{9}"/>
> 
> </xs:restriction>
> 
> </xs:simpleType>
> 
> 
> 
> When we generate the stubs using wsdl2java, the first one is getting
> generated as
> 
> 
> protected int ID;
> 
> and the second one is
> 
> protected Integer requestorID;
> 
> I did go through the Aegis default mapping details (
> http://cxf.apache.org/docs/aegis-theory-of-operation.html) and it says
> that
> xs:int can be mapped to int or Integer, but I'm curious to know why is
> this
> behaving differently. Is there a reason behind this or it is just random?
> If
> not, Is there a way to get this generated as an Integer. Or should we
> change
> the code manually? Is it a good practice to do that?
> 
> Would like to know if someone has faced this discrepancy before! Thanks..
> 
> 

-- 
View this message in context: http://old.nabble.com/wsdl2java-data-type-mapping-discrepancy-tp28624667p28628084.html
Sent from the cxf-user mailing list archive at Nabble.com.