It's not a secret anymore!*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Checke Unchecked exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Checke Unchecked exception" Watch "Checke Unchecked exception" New topic
Author

Checke Unchecked exception

davide boleso
Ranch Hand

Joined: Jul 15, 2012
Posts: 39
Still not clear if jax-ws in operation prefer checked vs unched.
I have read is better to translate checked in unchecked but how ? and why ?
thanks
Davide


OCPJP 6 | OCEJWSD 6 | OCEJWCD 6
Cosmin Nicolae Vacaroiu
Ranch Hand

Joined: Feb 10, 2011
Posts: 52

davide boleso wrote:Still not clear if jax-ws in operation prefer checked vs unched.
I have read is better to translate checked in unchecked but how ? and why ?
thanks
Davide


Only checked methods should have a soap Fault declared in WSDL, unchecked shouldn't be treated, but JAX-WS I think will generate a SOAP Fault response to the client in case of an unchecked exception.


SCJP 6 (93%), SQL Expert 11g (95%), SCWCD 6 (84%), OCE-EJBD 6 (98%), OCE-JPAD 6 (93%)
davide boleso
Ranch Hand

Joined: Jul 15, 2012
Posts: 39
Thanks Cosmin I have a mock that state

recommended way to deal with service specific exception

- Wrap the checked service specific exception and throw an unchecked exception
- Translate checked system exception to unchecked java exception and let the client application handle the unchecked exception

Still not sure what does it mean.
Actually I have learned how to extend Exception in your own exception and custom message and POJO object
thanks
Davide
Cosmin Nicolae Vacaroiu
Ranch Hand

Joined: Feb 10, 2011
Posts: 52

davide boleso wrote:Thanks Cosmin I have a mock that state

recommended way to deal with service specific exception

- Wrap the checked service specific exception and throw an unchecked exception
- Translate checked system exception to unchecked java exception and let the client application handle the unchecked exception

Still not sure what does it mean.
Actually I have learned how to extend Exception in your own exception and custom message and POJO object
thanks
Davide


I believe that you should send back to the client a certain Fault that's declared in the WSDL and the client knows about it, instead of letting jax-ws throw a somehow awkward Fault generated from that unchecked /exception.
davide boleso
Ranch Hand

Joined: Jul 15, 2012
Posts: 39
Probably the mock is not very accurate, please give a look


[Thumbnail for exception.png]

[Thumbnail for exception2.png]

Cosmin Nicolae Vacaroiu
Ranch Hand

Joined: Feb 10, 2011
Posts: 52

davide boleso wrote:Probably the mock is not very accurate, please give a look

Oh. I think this is the opposite. Maybe the WSDL doesn't have a fault declared, and you don't want to treat the exception yourself or hide it and the only way you can do this is wrapping int in an unchecked exception, since you can't throw a checked exception without declaring the method with throws.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1629
    
  23

Hi All,

I guess this is not a well asked question. First of all "Peter is creating a Web Service for his clients", but in the answers it also looks like he is creating the clients (answer A and D) to interact with them?!? Answer C is not correct according to the writer but a service specific exception can be mapped to an Exception which is defined in the Web Service interface (to let the client know that something is wrong), so I guess this answer can be regarded as a correct answer. Answer B also depends on what he has defined in his Web Service interface....

First of all I think that what Cosmin is saying is correct, catch the Service specific exception and throw an Exception (checked) that is declared in the Web Service interface (so that it will be mapped onto a wsdl:fault). In case of unrecoverable error or a system exception, these are, according to jax-ws, never mapped onto a a wsdl:fault message.

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checke Unchecked exception
 
Similar Threads
exceptions
Exception Doubt
NumberFormatException
Exception Handling with Webservices
Questions from mock Exam !!!