My understanding it CXF does not unmarshall JSON and returns (XML uses JAX-B for instance):
java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream cannot be cast to... http://stackoverflow.com/questions/26387208/how-create-a-java-object-from-cxf-webclient-response This http://www.hascode.com/2013/12/jax-rs-2-0-rest-client-features-by-example worked well with GlassFish Jersy/Jackson dependencies in TomEE. I just want to make sure I'm doing it in a portable way on TomEE with being able to handle client timeouts. On Wed, Apr 15, 2015 at 10:29 AM, Romain Manni-Bucau <[email protected]> wrote: > Weird, wonder if something else is broken. Can you try: post(versionDto /* > skip responseClass param to retrieve a Response */).readEntity( > VersionDto.class); > > Side note: using org.apache.cxf.jaxrs.client.WebClient#getConfig you can > get the conduit - getHttpConduit() - from a jaxrs cxf client (Client > or WebTarget) so no need to change all your code and use CXF proprietary > API for other parts. > > > Romain Manni-Bucau > @rmannibucau <https://twitter.com/rmannibucau> | Blog > <http://rmannibucau.wordpress.com> | Github < > https://github.com/rmannibucau> | > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber > <http://www.tomitribe.com> > > 2015-04-15 16:02 GMT+02:00 sgjava <[email protected]>: > > > I had JAX-RS POJO mapping working in TomEE using Jersey/Jackson > (Glassfish > > impl) with javax.ws.rs.* packages, but I wanted to use connect and read > > timeouts. As suggested I tried the CXF impl built into TomEE, but I > cannot > > get the response to map to the POJO. Here's the code in question: > > > > final WebClient client = WebClient.create(url, Collections. > > singletonList(new JacksonJsonProvider())); > > final HTTPConduit conduit = > > WebClient.getConfig(client).getHttpConduit(); > > conduit.getClient().setReceiveTimeout(7000); > > conduit.getClient().setConnectionTimeout(7000); > > final VersionDto versionDto = new VersionDto("xxx"); > > // This throws a 500 server exception > > final VersionDto response = client.type( > > MediaType.APPLICATION_JSON_TYPE).accept( > > MediaType.APPLICATION_JSON_TYPE).post(versionDto, > > VersionDto.class); > > > > // This will work but returns > > sun.net.www.protocol.http.HttpURLConnection$HttpInputStream > > final Response response = > > client.type(MediaType.APPLICATION_JSON_TYPE). > > accept(MediaType.APPLICATION_JSON_TYPE).post(versionDto); > > > > I'm not able to find any complete examples. > > > > > > > > -- > > View this message in context: > > > http://tomee-openejb.979440.n4.nabble.com/JAX-RS-POJO-mapping-tp4674454.html > > Sent from the TomEE Users mailing list archive at Nabble.com. > > > -- Steven P. Goldsmith
