You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by stlecho <st...@gmail.com> on 2008/04/17 12:27:18 UTC

Does JavaToWSDL support generics ?

Hi,

I would like to generate a WSDL for the following method: "public List<Car>
getAllCars();". In the generated WSDL I expect to have something similar to
'<xs:element
name="getAllCarsResponse"><xs:complexType><xs:sequence><xs:element
minOccurs="0" name="return" nillable="true"
type="xxx:Car"/></xs:sequence></xs:complexType></xs:element>'.

When using JavaToWSDL, the generated WSDL contains '<xsd:element
name="getAllCars" type="tns:getAllCars" /><xsd:complexType
name="getAllCars"><xsd:sequence /></xsd:complexType><xsd:element
name="getAllCarsResponse" type="tns:getAllCarsResponse" /><xsd:complexType
name="getAllCarsResponse"><xsd:sequence><xsd:element maxOccurs="unbounded"
minOccurs="0" name="return" /></xsd:sequence></xsd:complexType>'. There is
no reference to the 'Car' element :o(.

Based on this experience I was wondering if JavaToWSDL supports generics or
should I specify an additional parameter to generate a reference to the
'Car' element in the 'getAllCarsResponse' element ?

Regards, Stefan Lecho.
-- 
View this message in context: http://www.nabble.com/Does-JavaToWSDL-support-generics---tp16743152p16743152.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Does JavaToWSDL support generics ?

Posted by Daniel Kulp <dk...@apache.org>.
On Monday 21 April 2008, stlecho wrote:
> Ian,
>
> Unfortunately, Car is an interface and not a concrete class.

Yea, that would be the issue.  JAXB doesn't support interfaces directly, 
just concrete beans.   To get this to work, you would need to write an 
XmlJavaTypeAdapter to convert the Car objects to a concrete CarImpl or 
something that JAXB can deal with.   That said, I think that will only 
work with 2.1.  We actually have a sample that shows the TypeAdapters in 
the 2.1 kits in the sample/java_first_jaxws directory.

Dan


>
> Regards, Stefan Lecho.
>
> ianroberts wrote:
> > stlecho wrote:
> >> Hi,
> >>
> >> I would like to generate a WSDL for the following method: "public
> >> List<Car>
> >> getAllCars();".
> >
> > This should work as you expect, so long as Car is a concrete class
> > and not an interface.  If it's an interface things get more
> > difficult, but if you search for "interface" in the list archives
> > you should find several threads to help.
> >
> > Ian
> >
> > --
> > Ian Roberts               | Department of Computer Science
> > i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: Does JavaToWSDL support generics ?

Posted by stlecho <st...@gmail.com>.
Ian,

Unfortunately, Car is an interface and not a concrete class.

Regards, Stefan Lecho.


ianroberts wrote:
> 
> stlecho wrote:
>> Hi,
>> 
>> I would like to generate a WSDL for the following method: "public
>> List<Car>
>> getAllCars();".
> 
> This should work as you expect, so long as Car is a concrete class and 
> not an interface.  If it's an interface things get more difficult, but 
> if you search for "interface" in the list archives you should find 
> several threads to help.
> 
> Ian
> 
> -- 
> Ian Roberts               | Department of Computer Science
> i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK
> 
> 

-- 
View this message in context: http://www.nabble.com/Does-JavaToWSDL-support-generics---tp16743152p16807958.html
Sent from the cxf-user mailing list archive at Nabble.com.


unsubscribe

Posted by "Cobery, Marc" <mc...@rulestream.com>.

Re: Does JavaToWSDL support generics ?

Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
stlecho wrote:
> Hi,
> 
> I would like to generate a WSDL for the following method: "public List<Car>
> getAllCars();".

This should work as you expect, so long as Car is a concrete class and 
not an interface.  If it's an interface things get more difficult, but 
if you search for "interface" in the list archives you should find 
several threads to help.

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK

Re: Does JavaToWSDL support generics ?

Posted by Daniel Kulp <dk...@apache.org>.
Is there any chance you can send a war or other testcase that shows the 
issue?   If Car is really a concrete class (not an interface), this 
definitely should be working.   If it's not, I'd like to see a test case 
so I can dig in and figure out why.

Dan


On Monday 21 April 2008, stlecho wrote:
>   Dan,
>
> The original post was the output of CXF v2.0.5.
>
> When trying with CXF v2.1-incubator-snapshot of 2008-04-15, the
> "getAllCarsResponse" remains a sequence without any reference to the
> Car element: <xsd:element name="getAllCarsResponse"
> type="tns:getAllCarsResponse"/><xsd:complexType
> name="getAllCarsResponse"><xsd:sequence><xsd:element
> maxOccurs="unbounded" minOccurs="0"
> name="return"/></xsd:sequence></xsd:complexType>
>
> I've tried with 2 other methods that do not use generics, but in both
> cases the generated WSDL does not contain a reference to the Car
> element.
>
> Java method: public Car[] getAllCarsAsArray();
> Generated WSDL: <xsd:element name="getAllCarsAsArrayResponse"
> type="tns:getAllCarsAsArrayResponse"/><xsd:complexType
> name="getAllCarsAsArrayResponse"><xsd:sequence><xsd:element
> maxOccurs="unbounded" minOccurs="0"
> name="return"/></xsd:sequence></xsd:complexType>
>
> Java method: public Car getOneCar();
> Generated WSDL: <xsd:element name="getOneCar"
> type="tns:getOneCar"/><xsd:complexType
> name="getOneCar"><xsd:sequence/></xsd:complexType>
>
>
> Regards, Stefan Lecho.
>
> dkulp wrote:
> > What version of CXF?   That should definitely be working.
> >
> > Dan
> >
> > On Thursday 17 April 2008, stlecho wrote:
> >> Hi,
> >>
> >> I would like to generate a WSDL for the following method: "public
> >> List<Car> getAllCars();". In the generated WSDL I expect to have
> >> something similar to '<xs:element
> >> name="getAllCarsResponse"><xs:complexType><xs:sequence><xs:element
> >> minOccurs="0" name="return" nillable="true"
> >> type="xxx:Car"/></xs:sequence></xs:complexType></xs:element>'.
> >>
> >> When using JavaToWSDL, the generated WSDL contains '<xsd:element
> >> name="getAllCars" type="tns:getAllCars" /><xsd:complexType
> >> name="getAllCars"><xsd:sequence /></xsd:complexType><xsd:element
> >> name="getAllCarsResponse" type="tns:getAllCarsResponse"
> >> /><xsd:complexType
> >> name="getAllCarsResponse"><xsd:sequence><xsd:element
> >> maxOccurs="unbounded" minOccurs="0" name="return"
> >> /></xsd:sequence></xsd:complexType>'. There is no reference to the
> >> 'Car' element :o(.
> >>
> >> Based on this experience I was wondering if JavaToWSDL supports
> >> generics or should I specify an additional parameter to generate a
> >> reference to the 'Car' element in the 'getAllCarsResponse' element
> >> ?
> >>
> >> Regards, Stefan Lecho.
> >
> > --
> > J. Daniel Kulp
> > Principal Engineer, IONA
> > dkulp@apache.org
> > http://www.dankulp.com/blog



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog

Re: Does JavaToWSDL support generics ?

Posted by stlecho <st...@gmail.com>.
  Dan,

The original post was the output of CXF v2.0.5.

When trying with CXF v2.1-incubator-snapshot of 2008-04-15, the
"getAllCarsResponse" remains a sequence without any reference to the Car
element: <xsd:element name="getAllCarsResponse"
type="tns:getAllCarsResponse"/><xsd:complexType
name="getAllCarsResponse"><xsd:sequence><xsd:element maxOccurs="unbounded"
minOccurs="0" name="return"/></xsd:sequence></xsd:complexType>

I've tried with 2 other methods that do not use generics, but in both cases
the generated WSDL does not contain a reference to the Car element.

Java method: public Car[] getAllCarsAsArray();
Generated WSDL: <xsd:element name="getAllCarsAsArrayResponse"
type="tns:getAllCarsAsArrayResponse"/><xsd:complexType
name="getAllCarsAsArrayResponse"><xsd:sequence><xsd:element
maxOccurs="unbounded" minOccurs="0"
name="return"/></xsd:sequence></xsd:complexType>

Java method: public Car getOneCar();
Generated WSDL: <xsd:element name="getOneCar"
type="tns:getOneCar"/><xsd:complexType
name="getOneCar"><xsd:sequence/></xsd:complexType>


Regards, Stefan Lecho.


dkulp wrote:
> 
> 
> What version of CXF?   That should definitely be working.
> 
> Dan
> 
> 
> On Thursday 17 April 2008, stlecho wrote:
>> Hi,
>>
>> I would like to generate a WSDL for the following method: "public
>> List<Car> getAllCars();". In the generated WSDL I expect to have
>> something similar to '<xs:element
>> name="getAllCarsResponse"><xs:complexType><xs:sequence><xs:element
>> minOccurs="0" name="return" nillable="true"
>> type="xxx:Car"/></xs:sequence></xs:complexType></xs:element>'.
>>
>> When using JavaToWSDL, the generated WSDL contains '<xsd:element
>> name="getAllCars" type="tns:getAllCars" /><xsd:complexType
>> name="getAllCars"><xsd:sequence /></xsd:complexType><xsd:element
>> name="getAllCarsResponse" type="tns:getAllCarsResponse"
>> /><xsd:complexType
>> name="getAllCarsResponse"><xsd:sequence><xsd:element
>> maxOccurs="unbounded" minOccurs="0" name="return"
>> /></xsd:sequence></xsd:complexType>'. There is no reference to the
>> 'Car' element :o(.
>>
>> Based on this experience I was wondering if JavaToWSDL supports
>> generics or should I specify an additional parameter to generate a
>> reference to the 'Car' element in the 'getAllCarsResponse' element ?
>>
>> Regards, Stefan Lecho.
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer, IONA
> dkulp@apache.org
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/Does-JavaToWSDL-support-generics---tp16743152p16804887.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Does JavaToWSDL support generics ?

Posted by Daniel Kulp <dk...@apache.org>.
What version of CXF?   That should definitely be working.

Dan


On Thursday 17 April 2008, stlecho wrote:
> Hi,
>
> I would like to generate a WSDL for the following method: "public
> List<Car> getAllCars();". In the generated WSDL I expect to have
> something similar to '<xs:element
> name="getAllCarsResponse"><xs:complexType><xs:sequence><xs:element
> minOccurs="0" name="return" nillable="true"
> type="xxx:Car"/></xs:sequence></xs:complexType></xs:element>'.
>
> When using JavaToWSDL, the generated WSDL contains '<xsd:element
> name="getAllCars" type="tns:getAllCars" /><xsd:complexType
> name="getAllCars"><xsd:sequence /></xsd:complexType><xsd:element
> name="getAllCarsResponse" type="tns:getAllCarsResponse"
> /><xsd:complexType
> name="getAllCarsResponse"><xsd:sequence><xsd:element
> maxOccurs="unbounded" minOccurs="0" name="return"
> /></xsd:sequence></xsd:complexType>'. There is no reference to the
> 'Car' element :o(.
>
> Based on this experience I was wondering if JavaToWSDL supports
> generics or should I specify an additional parameter to generate a
> reference to the 'Car' element in the 'getAllCarsResponse' element ?
>
> Regards, Stefan Lecho.



-- 
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog