That's great. Is this included in one of the examples, or do you have 
something you can zip up and send me? The example set with CXF is 
brilliant - running stuff that actually works (with ant) makes the product 
so much easier to comprehend.


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

URL:  http://websso.cto.gt.intranet.db.com




"Sergey Beryozkin" <[EMAIL PROTECTED]> 
14/04/2008 09:54
Please respond to
[email protected]


To
<[email protected]>
cc

Subject
Re: REST, error handling, HTTP status codes






Hi


This would be fairly easy to do with JAX-RS. There's a number of ways to 
propogate HTTP errors with JAX-RS from your application code :

1. throw WenApplicationException

public void putIt(String s) {
    throw new WebApplicationException()
}

By default it will cause 500.

2. You can also use a Response object, either directly or by wrapping it 
into a WebApplicationException

public void putIt(String s) {
    throw new WebApplicationException(
         Response.status(406).entity(descitptionOfProblemInXml).build())
}

WebApplicationException is a RuntimeException so you can use (possibly) at 
any level in your app...

or 

just 

@ProduceMime("application/atom+entry")
@Path("{id}")
public Response getIt(Long id) {
       Entry e = find(id);
       if (e == null) {
           return 
Response.status(errorCode).entity(descitptionOfProblemInXml).build();
       } else {
           return Response.entity(e).build();
       } 
}

Cheers, Sergey




> Hello,
> 
> I'm looking into providing some REST based services with CXF. The 
examples 
> are great but I can't see something demonstrating error handling. While 
> error handling with REST doesn't seem to be particularly well defined, 
> HTTP status codes would surfice. How easy is this to achieve with CXF? 
> 
> 
> John Baker
> -- 
> Web SSO 
> IT Infrastructure 
> Deutsche Bank London
> 
> URL:  http://websso.cto.gt.intranet.db.com
> 
> 
> ---
> 
> This e-mail may contain confidential and/or privileged information. If 
you are not the intended recipient (or have received this e-mail in error) 
please notify the sender immediately and delete this e-mail. Any 
unauthorized copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
> 
> Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
additional EU corporate and regulatory disclosures.

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland



---

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient (or have received this e-mail in error) please 
notify the sender immediately and delete this e-mail. Any unauthorized copying, 
disclosure or distribution of the material in this e-mail is strictly forbidden.

Please refer to http://www.db.com/en/content/eu_disclosures.htm for additional 
EU corporate and regulatory disclosures.

Reply via email to