Again, as I said before, I'm not an expert on xfire exceptions by any means, I
never completely got mine to work the way I intended to. But, having said that,
I would think it would be much simpler to actually throw a FaultInfoException
from every service method. This is where the error naturally occurs, when you
try to commit something to the database. So you have to already somehow catch
the exception there, so why not just re-throw it as an instance of
FaultInfoException? Besides, if you do it using handlers instead, I dont think
xfire will put a fault message part in the WSDL. I think the way xfire knows
that the service can throw an exception is by inspecting the service method
definitions.
Also, a third alternative is to alter your response message from something
like:
<stuff/>
to:
<Success>
<stuff/>
</Success>
<Failure>
<error>SQL Code....</error>
<error>SQL Code....</error>
</Failure>
and return the failures as part of the normal response message. I would only
do this if your errors are business rule/validation errors (which "duplicate
records" might be). If your errors are actual application faults, then you
should probably go with throwing exceptions. This is just from the logical
design point of view.
Hope this helps.
Andrey
"R.A" <[EMAIL PROTECTED]> wrote:
Hi Andrey,
Thank you for your reply, and ï½orry for not writing you soon.
Using FaultInfoException, I have to throw this subclass in all service
methods.
So I think using FaultHandler and set error codes in this FaultHandler
class.
public class MyFaultHandler extends AbstractHandler {
public void invoke(MessageContext context) throws Exception {
Exception e = (Exception) context.getProperty("exception");
// I'd like to get sqlState and errorCode by some means.
XFireFault fault = (XFireFault)
context.getExchange().getFaultMessage().getBody();
fault.setMessage("SQL state=" + sqlState + ", error code=" + errorCode);
}
}
For example, duplication entry exception occur, I get these stack trace.
2007-03-27 16:05:34,296 WARN [org.hibernate.util.JDBCExceptionReporter] -
SQL Error: 1062, SQLState: 23000
2007-03-27 16:05:34,296 ERROR [org.hibernate.util.JDBCExceptionReporter] -
Duplicate entry '15' for key 1
2007-03-27 16:05:34,296 ERROR
[org.hibernate.event.def.AbstractFlushingEventListener] - Could not
synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC
batch update
at
org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
I'd like to get "SQL Error: 1062, SQLState: 23000" in MyFaultHandler class,
JDBCExceptionReporter output that.
Do you have any idea?
Regards,
R.A
--
View this message in context:
http://www.nabble.com/How-do-I-get--error-code--tf3446648.html#a9687516
Sent from the XFire - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email
---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.