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
[email protected] <mailto:[email protected]> skype: orangebits