You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by CFX Novice <su...@gmail.com> on 2008/06/17 15:16:25 UTC

Re: REST, error handling, HTTP status codes

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 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