I was able to get the exception to return to the client (and it was published
in the WSDL as well) by throwing an exception that extends FaultInfoException
like this:
public class MsgException extends FaultInfoException {
private MsgExceptionDetail faultDetail;
public MsgException(MsgExceptionDetail e) {
super();
faultDetail = e;
}
public MsgExceptionDetail getFaultInfo() {
return faultDetail;
}
public static QName getFaultName() {
return new QName("blah", "MsgExceptionDetail");
}
}
Where MsgExceptionDetail is the class that contains whatever details your
exception has. Unfortunately, what happens on the client side (XFire w/JiBX
client) is that it throws an XFireRuntimeException, and you can sort of
retrieve the MsgExceptionDetail from the detail field of this exception, but
the field is an instance of Element (DOM), not an actual instance of the
MsgException or MsgExceptionDetail class. It seems XFire doesn't use the XML
binding that it uses for regular input/output for the exceptions. In my case,
it turned out that I didnt really need to throw an exception, so I stopped
investigating. So perhaps there's a better way to get the exception than this?
Andrey
"R.A" <[EMAIL PROTECTED]> wrote:
Hi all,
I'm trying to create web services using xfire + spring + hibernate.
I'd like to get error codes of MySQL when the database work exceptionally.
I create a exception class that extends FaultInfoException and I have a sql
error codes trasnlator class that extends
SQLErrorCodeSQLExceptionTranslator.
But I don't know how connect these two classes and I don't have a better
idea.
Please help!
public class BookServiceImpl implements BookService {
private BookDao bookDao;
public Book getBook(int id) {
// Do I throw the BookException? But how do I get the error code?
return bookDao;
}
}
public class BookException extends FaultInfoException {
private BookExceptionDetail faultDetail;
public BookException(String msg,BookExceptionDetail details){
super(msg);
faultDetail=details;
}
public BookExceptionDetail getFaultInfo() {
return faultDetail;
}
public static QName getFaultName() {
return new QName("http://sample.net", "BookFault");
}
}
public class MySQLErrorCodesTranslator extends
SQLErrorCodeSQLExceptionTranslator {
protected DataAccessException customTranslate(String task, String sql,
SQLException sqlex) {
int errorCode = sqlex.getErrorCode(); // I can get a error code here.
// but what to do after this?
}
}
Regards,
R.A
--
View this message in context:
http://www.nabble.com/How-do-I-get--error-code--tf3446648.html#a9611854
Sent from the XFire - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel
bargains.