[ 
https://issues.apache.org/jira/browse/CXF-4849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13585844#comment-13585844
 ] 

Raj Anand commented on CXF-4849:
--------------------------------

Sergey,

I tried this feature with CXF 2.7.4-SNAPSHOT version and got the following 
exception when trying to fetch the payload(generic type) from the 
response(which is a parameterized class , ServiceResponse<T>).

java.lang.ClassCastException: 
com.sun.org.apache.xerces.internal.dom.ElementNSImpl cannot be cast to 
examples.service.Book.

Here Book is the payload class(Generic Type).

Following is the snippet of the code I am using,

GenericType<ServiceResponse<Book>> genericResponseType = new 
GenericType<ServiceResponse<Book>>() {};
ServiceResponse<Book> res = webclient.get(genericResponseType);
...
assertFalse(!res.getPayload()); //throws ClassCastException as, res.getPayload 
is of type Book, but at runtime its replaced by ElementNSImpl

ServiceResponse is the parameterized class with Book as payload.

Let me know if something is missing or erroneous here.

-Raj Anand
                
> WebClient needs to support JAX-RS 2.0 GenericType
> -------------------------------------------------
>
>                 Key: CXF-4849
>                 URL: https://issues.apache.org/jira/browse/CXF-4849
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>            Reporter: Sergey Beryozkin
>            Assignee: Sergey Beryozkin
>             Fix For: 2.8.0, 2.7.4
>
>
> This is useful for processing generic responses, example,
> {code:java}
> GenericType<List<Book>> genericResponseType = new GenericType<List<Book>>() 
> {};
> List<Book> books = webClient.get(genericResponseType);
> // or
> List<Book> books = webClient.post(someObject, genericResponseType);
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to