You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Ray Chen <ra...@gmail.com> on 2013/11/15 18:55:41 UTC

About the CXF exception when making the rest call

Hi all,

Currently, we are using the cxf-rt-frontend-jaxrs-2.3.7, jetty-http-7.2.2,
and jsr311-api-1.1.1 for handling the rest call.

But when exception happens, we could not recover the json payload from the
ServerWebApplicationException.

  public <T> T invoke(String httpMethod, Object body, Class<T>
responseClass)
  {
    Response r = doInvoke(httpMethod, body, responseClass, responseClass);
    if ((r.getStatus() >= 400) && (responseClass != null)) {
      throw new ServerWebApplicationException(r);
    }
    return responseClass.cast(r.getEntity());
  }

I wonder if anyone experience the similar things like that.

Thanks very much for your time to look at it.
Ray

Re: About the CXF exception when making the rest call

Posted by Sergey Beryozkin <sb...@gmail.com>.
thanks Dan, yes, JAX-RS 2.0 Response.readEntity can do it,
Cheers, Sergey
On 15/11/13 18:29, Daniel Kulp wrote:
>
> On Nov 15, 2013, at 12:55 PM, Ray Chen <ra...@gmail.com> wrote:
>
>> Hi all,
>>
>> Currently, we are using the cxf-rt-frontend-jaxrs-2.3.7, jetty-http-7.2.2,
>
> These are ancient versions.  Quite unsupported at this point.   Can you try with a more recent version of CXF and see if you still have an issue?
>
> Thanks!
> Dan
>
>
>
>> and jsr311-api-1.1.1 for handling the rest call.
>>
>> But when exception happens, we could not recover the json payload from the
>> ServerWebApplicationException.
>>
>>   public <T> T invoke(String httpMethod, Object body, Class<T>
>> responseClass)
>>   {
>>     Response r = doInvoke(httpMethod, body, responseClass, responseClass);
>>     if ((r.getStatus() >= 400) && (responseClass != null)) {
>>       throw new ServerWebApplicationException(r);
>>     }
>>     return responseClass.cast(r.getEntity());
>>   }
>>
>> I wonder if anyone experience the similar things like that.
>>
>> Thanks very much for your time to look at it.
>> Ray
>


Re: About the CXF exception when making the rest call

Posted by Daniel Kulp <dk...@apache.org>.
On Nov 15, 2013, at 12:55 PM, Ray Chen <ra...@gmail.com> wrote:

> Hi all,
> 
> Currently, we are using the cxf-rt-frontend-jaxrs-2.3.7, jetty-http-7.2.2,

These are ancient versions.  Quite unsupported at this point.   Can you try with a more recent version of CXF and see if you still have an issue?

Thanks!
Dan



> and jsr311-api-1.1.1 for handling the rest call.
> 
> But when exception happens, we could not recover the json payload from the
> ServerWebApplicationException.
> 
>  public <T> T invoke(String httpMethod, Object body, Class<T>
> responseClass)
>  {
>    Response r = doInvoke(httpMethod, body, responseClass, responseClass);
>    if ((r.getStatus() >= 400) && (responseClass != null)) {
>      throw new ServerWebApplicationException(r);
>    }
>    return responseClass.cast(r.getEntity());
>  }
> 
> I wonder if anyone experience the similar things like that.
> 
> Thanks very much for your time to look at it.
> Ray

-- 
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com