cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Schipperheyn <m...@orangebits.nl>
Subject Re: JAX-RS: inheritance in server method
Date Mon, 20 Dec 2010 10:32:04 GMT
Tried removing the XmlRootElement tag from ParentVO: same result
Tried removing the XmlRootElement tag from ParentVO and making it 
abstract which results in an unspecified 500 error, which is not logged 
on the server.

There seems to be an irresistible desire to cast down to the base class. 
:-) Very confusing.

BTW I see that the mailing list removed destroyed some code here:
public classChildVO extends ParentVO{
String label;
int count;
}

public class RequestObject<T extends ParentVO>{
T vo;
}

I assume that the T extends ParentVO is the culprit here. Because, 
regardless of what I do, Everything leaves as a ChildVO but arrives as a 
ParentVO.
It would also explain why making ParentVO abstract doesn't work. 
Apparently, it tries to instantiate ParentVO.

So, is this some kind of bug or am I doing some wrong? Do I need to 
implement some custom processing? It all seems illogical to me.

On 20-12-2010 10:44, Marc Schipperheyn wrote:
> I have both ParentVO and ChildVO tagged as XmlRootElement
> @XmlRootElement(name = "parent")
> public class ParentVO
>
> @XmlRootElement(name = "child")
> public class ChildVO
>
>
> On 20-12-2010 10:15, Marc Schipperheyn wrote:
>> Hi,
>>
>> I'm using JAX-RS and spring 3. I have a problem with inheritance on 
>> the receiving end of the service and I'm wondering if there is a way 
>> to work around this.
>> PHP Code:
>> ||Types of beans sent
>> publicclassParentVO{
>> String label;
>> }
>> publicclassChildVOextendsParentVO{
>> String label;
>> int count;
>> }
>>
>> client
>> ChildVO vo= newChildVO();
>> vo.setLabel("Hello");
>> vo.setCount(1);
>> RequestObject request= newRequestObject();
>> request.setVO(vo);
>>
>> ResponseObject response=importProxy.importContent(request);
>> ||
>> PHP Code:
>> ||publicclassRequestObject{
>> ParentVO vo;
>> }
>>
>> Server JAX-RS client
>>
>> @POST
>> @Path("/import/standard")
>>     @Secured({"ROLE_WS","ROLE_ADMIN"})
>>     @Produces("text/xml")
>> public ResponseObject importContent(RequestObject bean){
>> }
>> ||
>> I'm trying to work with a single importContent method in stead of 
>> creating one specific to eaach type of bean.
>>
>> But "vo" is always of type ParentVO including when a ChildVO is sent.
>>
>> Is there a way to do this with JAX-RS?
>>
>> I've also tried the following with the same result.
>> PHP Code:
>> ||client
>> ChildVO vo= newChildVO();
>> vo.setLabel("Hello");
>> vo.setCount(1);
>>
>> RequestObject<ChildVO>request= newRequestObject<ChildVO>();
>> request.setVO(vo);
>>
>> ResponseObject response=importProxy.importContent(request);
>> ResponseObject response=importProxy.importChild(request);
>> ||
>> PHP Code:
>> ||publicclassRequestObject<TextendsParentVO>{
>> T vo;
>> }
>>
>> Server JAX-RS client
>>
>> @POST
>> @Path("/import/standard")
>>     @Secured({"ROLE_WS","ROLE_ADMIN"})
>>     @Produces("text/xml")
>> public ResponseObject importContent(RequestObject bean){
>> }
>>
>> @POST
>> @Path("/import/standard")
>>     @Secured({"ROLE_WS","ROLE_ADMIN"})
>>     @Produces("text/xml")
>> public ResponseObject importChild(RequestObject<ChildVO>bean){
>> }
>> ||
>> In the case above both importContent and importChild produced a vo of 
>> type ParentVO, which surprised me.
>>
>> Any suggestions? Primarily, I would like to avoid unique method 
>> signatures for each child.
>> I'm using Spring 3.0.5 and CXF 2.3.0
>>
>> Kind regards,
>>
>> Marc
>>
>>
>>
>>
>>
>>
>>
>

-- 

M.Schipperheyn
/Principal Consultant/

Orange bits

www.orangebits.nl <http://www.orangebits.nl> 	t: +31 6 218 03 003
marc@orangebits.nl <mailto:marc@orangebits.nl> 	skype: orangebits


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message