You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "krn1231@gmail.com" <kr...@gmail.com> on 2011/11/03 07:14:09 UTC
Exception handling inside Apache CXF Webservices
I have developed a webservice using Apache CXF ,which will be in production
very soon . I am concerned about the exception handling in this , i am not
sure whether what i followed is correct or not .
I have a method shown below which i exposed i as a webservice
import javax.jws.WebService;
@WebService
public interface TataWebService {
public String distragery()throws Exception;
}
public String distrager throws Exception {
int a = 30;
strategyData = "currentlyhadcoced" ;
if(a==30)
{
throw new IncorrectProjectIdsException("The Value of a is 30");
}
return strategyData;
And the way i defined User defined exception is this way
@WebFault(name = "IncorrectProjectIdsDetails")
public class IncorrectProjectIdsException extends Exception {
private java.lang.String incorrectProjectIdsDetails;
public IncorrectProjectIdsException (String message) {
super(message);
}
public java.lang.String getFaultInfo() {
return this.incorrectProjectIdsDetails;
}
}
Please tell me if this is correct , regarding the throws declaration inside
the method signature or shuld we handle in any other manner ??
Thank you very much
--
View this message in context: http://cxf.547215.n5.nabble.com/Exception-handling-inside-Apache-CXF-Webservices-tp4960248p4960248.html
Sent from the cxf-user mailing list archive at Nabble.com.
Re: Exception handling inside Apache CXF Webservices
Posted by Daniel Kulp <dk...@apache.org>.
It's "correct enough". However, usually, the getFaultInfo() would return a
JAXB bean that defines the content for the detail element in the message.
Dan
On Wednesday, November 02, 2011 11:14:09 PM krn1231@gmail.com wrote:
> I have developed a webservice using Apache CXF ,which will be in production
> very soon . I am concerned about the exception handling in this , i am not
> sure whether what i followed is correct or not .
>
> I have a method shown below which i exposed i as a webservice
>
> import javax.jws.WebService;
>
> @WebService
> public interface TataWebService {
> public String distragery()throws Exception;
>
> }
> public String distrager throws Exception {
>
> int a = 30;
> strategyData = "currentlyhadcoced" ;
>
> if(a==30)
> {
> throw new IncorrectProjectIdsException("The Value of a is 30");
> }
>
> return strategyData;
> And the way i defined User defined exception is this way
>
> @WebFault(name = "IncorrectProjectIdsDetails")
>
> public class IncorrectProjectIdsException extends Exception {
>
> private java.lang.String incorrectProjectIdsDetails;
>
> public IncorrectProjectIdsException (String message) {
> super(message);
> }
>
> public java.lang.String getFaultInfo() {
> return this.incorrectProjectIdsDetails;
> }
> }
> Please tell me if this is correct , regarding the throws declaration inside
> the method signature or shuld we handle in any other manner ??
>
> Thank you very much
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/Exception-handling-inside-Apache-CXF-Webser
> vices-tp4960248p4960248.html Sent from the cxf-user mailing list archive at
> Nabble.com.
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog
Talend - http://www.talend.com