You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by John-M Baker <jo...@db.com> on 2008/04/14 10:02:00 UTC

REST, error handling, HTTP status codes

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.

Re: REST, error handling, HTTP status codes

Posted by CFX Novice <su...@gmail.com>.
Thanks,

That worked.


Sergey Beryozkin wrote:
> 
> Hi
> 
> You can do 
> 
> new
> WebApplicationException(Response.status(...).entity(formatErrorMessageAsNeeded()).build())
> 
> 
> Once ExceptionMapper providers are supported, one'll be able to
> 
> throw custom exceptions from the application code and deal with the way
> the exception is serialized in a seperate provider...
> 
> Cheers, Sergey
> 
> 
> 
>> 
>> Hi,
>> 
>> I'm making an AJAX request to a REST service.I'm trying to return a JSON
>> response from my service class method. So if the method throws a
>> WebApplicationException I get an error like:"XML Parsing Error: no
>> element
>> found"
>> 
>> Is there something I need to do to be able to marshal the
>> WebApplicationException? 
>> 
>> 
>> 
>> Sergey Beryozkin wrote:
>>> 
>>> Hi
>>> 
>>>> It probably just needs a little work to expand on some of the topics to 
>>>> answer questions covering status codes, security, etc.
>>> 
>>> Agreed :-). 
>>> 
>>> By the way, Jervis added a demo awhile back showing how to secure JAX-RS
>>> endpoints with HTTPs.
>>> CXF JAX-RS sits on top of Apache Abdera which does XML Dig
>>> Signature/Encryption for Atom, so perhaps, when Atom is used, the
>>> advanced
>>> message-level security will be supported out of the box, not sure though
>>> about it, perhaps an Atom JAX-RS provider will need to be updated a
>>> bit...
>>> 
>>> Cheers, Sergey
>>> 
>>> 
>>>> Hiya,
>>>> 
>>>> I'll look at 2.1. This document is very useful:
>>>> 
>>>> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
>>>> 
>>>> It probably just needs a little work to expand on some of the topics to 
>>>> answer questions covering status codes, security, etc.
>>>> 
>>>> 
>>>> John Baker
>>>> -- 
>>>> Web SSO 
>>>> IT Infrastructure 
>>>> Deutsche Bank London
>>>> 
>>>> URL:  http://websso.cto.gt.intranet.db.com
>>>> 
>>>> 
>>>> 
>>>> 
>>>> "Sergey Beryozkin" <se...@iona.com> 
>>>> 14/04/2008 10:23
>>>> Please respond to
>>>> cxf-user@incubator.apache.org
>>>> 
>>>> 
>>>> To
>>>> <cx...@incubator.apache.org>
>>>> cc
>>>> 
>>>> Subject
>>>> Re: REST, error handling, HTTP status codes
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Hi
>>>> 
>>>> It's shipped with 2.1-SNAPSHOT.
>>>> Have a look please at a few JAX-RS demos available in the distribution.
>>>> 
>>>> I was also about to create a demo showing how one can easily do AtomPub 
>>>> with CXF and JAX-RS but I haven't had time due to time constraints. 
>>>> 
>>>> I've promised a number of times to document what one can do with CXF
>>>> and 
>>>> JAX-RS, haven't had time to do it either, but with the 2.1 release 
>>>> approaching (according to Dan) I'll need to do it soon. 
>>>> 
>>>> CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy,
>>>> Restlests 
>>>> are working with 0.7. CXF JAX-RS is likely to be able to support a
>>>> number 
>>>> of scenarious, due its good and simple integration with Spring. 
>>>> 
>>>> Cheers, Sergey
>>>> 
>>>> 
>>>>> Is jax-rs included 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. 
>>> 
>>> ----------------------------
>>> IONA Technologies PLC (registered in Ireland)
>>> Registered Number: 171387
>>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4,
>>> Ireland
>>> 
>>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/REST%2C-error-handling%2C-HTTP-status-codes-tp16673446p17900862.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: http://www.nabble.com/REST%2C-error-handling%2C-HTTP-status-codes-tp16673446p17974118.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: REST, error handling, HTTP status codes

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

You can do 

new WebApplicationException(Response.status(...).entity(formatErrorMessageAsNeeded()).build())


Once ExceptionMapper providers are supported, one'll be able to

throw custom exceptions from the application code and deal with the way the exception is serialized in a seperate provider...

Cheers, Sergey



> 
> Hi,
> 
> I'm making an AJAX request to a REST service.I'm trying to return a JSON
> response from my service class method. So if the method throws a
> WebApplicationException I get an error like:"XML Parsing Error: no element
> found"
> 
> Is there something I need to do to be able to marshal the
> WebApplicationException? 
> 
> 
> 
> Sergey Beryozkin wrote:
>> 
>> Hi
>> 
>>> It probably just needs a little work to expand on some of the topics to 
>>> answer questions covering status codes, security, etc.
>> 
>> Agreed :-). 
>> 
>> By the way, Jervis added a demo awhile back showing how to secure JAX-RS
>> endpoints with HTTPs.
>> CXF JAX-RS sits on top of Apache Abdera which does XML Dig
>> Signature/Encryption for Atom, so perhaps, when Atom is used, the advanced
>> message-level security will be supported out of the box, not sure though
>> about it, perhaps an Atom JAX-RS provider will need to be updated a bit...
>> 
>> Cheers, Sergey
>> 
>> 
>>> Hiya,
>>> 
>>> I'll look at 2.1. This document is very useful:
>>> 
>>> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
>>> 
>>> It probably just needs a little work to expand on some of the topics to 
>>> answer questions covering status codes, security, etc.
>>> 
>>> 
>>> John Baker
>>> -- 
>>> Web SSO 
>>> IT Infrastructure 
>>> Deutsche Bank London
>>> 
>>> URL:  http://websso.cto.gt.intranet.db.com
>>> 
>>> 
>>> 
>>> 
>>> "Sergey Beryozkin" <se...@iona.com> 
>>> 14/04/2008 10:23
>>> Please respond to
>>> cxf-user@incubator.apache.org
>>> 
>>> 
>>> To
>>> <cx...@incubator.apache.org>
>>> cc
>>> 
>>> Subject
>>> Re: REST, error handling, HTTP status codes
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> Hi
>>> 
>>> It's shipped with 2.1-SNAPSHOT.
>>> Have a look please at a few JAX-RS demos available in the distribution.
>>> 
>>> I was also about to create a demo showing how one can easily do AtomPub 
>>> with CXF and JAX-RS but I haven't had time due to time constraints. 
>>> 
>>> I've promised a number of times to document what one can do with CXF and 
>>> JAX-RS, haven't had time to do it either, but with the 2.1 release 
>>> approaching (according to Dan) I'll need to do it soon. 
>>> 
>>> CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy,
>>> Restlests 
>>> are working with 0.7. CXF JAX-RS is likely to be able to support a number 
>>> of scenarious, due its good and simple integration with Spring. 
>>> 
>>> Cheers, Sergey
>>> 
>>> 
>>>> Is jax-rs included 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. 
>> 
>> ----------------------------
>> IONA Technologies PLC (registered in Ireland)
>> Registered Number: 171387
>> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>> 
>> 
> 
> -- 
> View this message in context: http://www.nabble.com/REST%2C-error-handling%2C-HTTP-status-codes-tp16673446p17900862.html
> Sent from the cxf-user mailing list archive at Nabble.com.

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

Re: REST, error handling, HTTP status codes

Posted by CFX Novice <su...@gmail.com>.
Hi,

I'm making an AJAX request to a REST service.I'm trying to return a JSON
response from my service class method. So if the method throws a
WebApplicationException I get an error like:"XML Parsing Error: no element
found"

Is there something I need to do to be able to marshal the
WebApplicationException? 



Sergey Beryozkin wrote:
> 
> Hi
> 
>> It probably just needs a little work to expand on some of the topics to 
>> answer questions covering status codes, security, etc.
> 
> Agreed :-). 
> 
> By the way, Jervis added a demo awhile back showing how to secure JAX-RS
> endpoints with HTTPs.
> CXF JAX-RS sits on top of Apache Abdera which does XML Dig
> Signature/Encryption for Atom, so perhaps, when Atom is used, the advanced
> message-level security will be supported out of the box, not sure though
> about it, perhaps an Atom JAX-RS provider will need to be updated a bit...
> 
> Cheers, Sergey
> 
> 
>> Hiya,
>> 
>> I'll look at 2.1. This document is very useful:
>> 
>> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
>> 
>> It probably just needs a little work to expand on some of the topics to 
>> answer questions covering status codes, security, etc.
>> 
>> 
>> John Baker
>> -- 
>> Web SSO 
>> IT Infrastructure 
>> Deutsche Bank London
>> 
>> URL:  http://websso.cto.gt.intranet.db.com
>> 
>> 
>> 
>> 
>> "Sergey Beryozkin" <se...@iona.com> 
>> 14/04/2008 10:23
>> Please respond to
>> cxf-user@incubator.apache.org
>> 
>> 
>> To
>> <cx...@incubator.apache.org>
>> cc
>> 
>> Subject
>> Re: REST, error handling, HTTP status codes
>> 
>> 
>> 
>> 
>> 
>> 
>> Hi
>> 
>> It's shipped with 2.1-SNAPSHOT.
>> Have a look please at a few JAX-RS demos available in the distribution.
>> 
>> I was also about to create a demo showing how one can easily do AtomPub 
>> with CXF and JAX-RS but I haven't had time due to time constraints. 
>> 
>> I've promised a number of times to document what one can do with CXF and 
>> JAX-RS, haven't had time to do it either, but with the 2.1 release 
>> approaching (according to Dan) I'll need to do it soon. 
>> 
>> CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy,
>> Restlests 
>> are working with 0.7. CXF JAX-RS is likely to be able to support a number 
>> of scenarious, due its good and simple integration with Spring. 
>> 
>> Cheers, Sergey
>> 
>> 
>>> Is jax-rs included 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. 
> 
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
> 
> 

-- 
View this message in context: http://www.nabble.com/REST%2C-error-handling%2C-HTTP-status-codes-tp16673446p17900862.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: REST, error handling, HTTP status codes

Posted by John-M Baker <jo...@db.com>.
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" <se...@iona.com> 
14/04/2008 09:54
Please respond to
cxf-user@incubator.apache.org


To
<cx...@incubator.apache.org>
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.

Re: REST, error handling, HTTP status codes

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

> It probably just needs a little work to expand on some of the topics to 
> answer questions covering status codes, security, etc.

Agreed :-). 

By the way, Jervis added a demo awhile back showing how to secure JAX-RS endpoints with HTTPs.
CXF JAX-RS sits on top of Apache Abdera which does XML Dig Signature/Encryption for Atom, so perhaps, when Atom is used, the advanced message-level security will be supported out of the box, not sure though about it, perhaps an Atom JAX-RS provider will need to be updated a bit...

Cheers, Sergey


> Hiya,
> 
> I'll look at 2.1. This document is very useful:
> 
> http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html
> 
> It probably just needs a little work to expand on some of the topics to 
> answer questions covering status codes, security, etc.
> 
> 
> John Baker
> -- 
> Web SSO 
> IT Infrastructure 
> Deutsche Bank London
> 
> URL:  http://websso.cto.gt.intranet.db.com
> 
> 
> 
> 
> "Sergey Beryozkin" <se...@iona.com> 
> 14/04/2008 10:23
> Please respond to
> cxf-user@incubator.apache.org
> 
> 
> To
> <cx...@incubator.apache.org>
> cc
> 
> Subject
> Re: REST, error handling, HTTP status codes
> 
> 
> 
> 
> 
> 
> Hi
> 
> It's shipped with 2.1-SNAPSHOT.
> Have a look please at a few JAX-RS demos available in the distribution.
> 
> I was also about to create a demo showing how one can easily do AtomPub 
> with CXF and JAX-RS but I haven't had time due to time constraints. 
> 
> I've promised a number of times to document what one can do with CXF and 
> JAX-RS, haven't had time to do it either, but with the 2.1 release 
> approaching (according to Dan) I'll need to do it soon. 
> 
> CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy, Restlests 
> are working with 0.7. CXF JAX-RS is likely to be able to support a number 
> of scenarious, due its good and simple integration with Spring. 
> 
> Cheers, Sergey
> 
> 
>> Is jax-rs included 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. 

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

Re: REST, error handling, HTTP status codes

Posted by John-M Baker <jo...@db.com>.
Hiya,

I'll look at 2.1. This document is very useful:

http://cwiki.apache.org/CXF20DOC/jax-rs-jsr-311.html

It probably just needs a little work to expand on some of the topics to 
answer questions covering status codes, security, etc.


John Baker
-- 
Web SSO 
IT Infrastructure 
Deutsche Bank London

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




"Sergey Beryozkin" <se...@iona.com> 
14/04/2008 10:23
Please respond to
cxf-user@incubator.apache.org


To
<cx...@incubator.apache.org>
cc

Subject
Re: REST, error handling, HTTP status codes






Hi

It's shipped with 2.1-SNAPSHOT.
Have a look please at a few JAX-RS demos available in the distribution.

I was also about to create a demo showing how one can easily do AtomPub 
with CXF and JAX-RS but I haven't had time due to time constraints. 

I've promised a number of times to document what one can do with CXF and 
JAX-RS, haven't had time to do it either, but with the 2.1 release 
approaching (according to Dan) I'll need to do it soon. 

CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy, Restlests 
are working with 0.7. CXF JAX-RS is likely to be able to support a number 
of scenarious, due its good and simple integration with Spring. 

Cheers, Sergey


> Is jax-rs included 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.

Re: REST, error handling, HTTP status codes

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

It's shipped with 2.1-SNAPSHOT.
Have a look please at a few JAX-RS demos available in the distribution.

I was also about to create a demo showing how one can easily do AtomPub with CXF and JAX-RS but I haven't had time due to time constraints. 

I've promised a number of times to document what one can do with CXF and JAX-RS, haven't had time to do it either, but with the 2.1 release approaching (according to Dan) I'll need to do it soon. 

CXF JAX-RS support 0.6 version of jsr-311 api. Jersey, RestEasy, Restlests are working with 0.7. CXF JAX-RS is likely to be able to support a number of scenarious, due its good and simple integration with Spring. 

Cheers, Sergey


> Is jax-rs included 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

Re: REST, error handling, HTTP status codes

Posted by John-M Baker <jo...@db.com>.
Is jax-rs included 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.

Re: REST, error handling, HTTP status codes

Posted by Sergey Beryozkin <se...@iona.com>.
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