On May 16, 2013, at 7:10 PM, Guillermo Lopez Mackinnon 
<[email protected]> wrote:

> Hi,
> I'm developing a web service and I need it to accept a polymorphic
> parameter. For example, imagine an operation named
> processRequests(List<Request> requests) which may accept a "Request" and a
> "CustomRequest" type (extending from Request) and possibly some others. It
> is my understanding that it should be possible to achieve however no matter
> how I do it I allways get the parameter unmarshaled as the base class and
> if I place any of the subtype's properties I get an unmarshall exception
> (unexpected element).
> 
> I'm testing by using SOAP UI and the request parameter is as the following:
> 
> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:type="customRequest">
> </request>
> And the pojos look as the following:
> 
> 
> @XmlRootElement
> @XmlSeeAlso({CustomRequest.class})
> publc class Request {}
> 
> public class CustomRequest extends Request{}
> 
> It may be worth to note that I'm developing this as an EJB web service with
> JBoss 7 and I'd say the cxf version is 2.4.8.
> 
> I'd say this should work but I cannot get it to work...
> 
> Moreover the wsdl does not displays the subtype definition so I had to
> manually add this definition but the situation has not changed.


If the WSDL doesn't contain the type, then JAXB wouldn't know about it and 
nothing would work.  Adding it by hand wouldn't help. 

Do both Request and CustomRequest have an @XmlType annotation on them with a 
non-empty name attribute?   If not, try adding that.   The XmlRootElement 
annotation on Request is likely creating a root element with an anonymous type 
in it. You cannot "extend" that type of Type in the wsdl so it's possible that 
that is the reason.   

If that doesn't help, please log an issue with a simple test case.

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to