Thanks very much for the thread 
I got a better solution from reamon:
http://www.wmusers.com/forum/showthread.php?p=81839#post81839
Create a java service that accept a string and throw ServiceException, call the java service instead of EXIT from $parent and signal Failure. In CATCH sequence, you can call getLastError to retrieve the variables set in TRY sequence which reside at lastError/pipeline document.
Thus, for the example above, the variable “abc” can be accessed from %lastError/pipeline/abc% by using variable substitution.
Let’s say the java service is com.mycompany.util.throwException. So the code should be like this:
MAP -> set string variable "abc" to value "0"
SEQUENCE (TRY & CATCH)
SEQUENCE (TRY)
MAP -> set string variable "abc" to value "1"
[B]Invoke: com.mycompany.util.throwException[/b]
SEQUENCE (CATCH)
[B]Invoke: pub.flow:getLastError[/b]
Invoke: pub.flow:debugLog (I print the value of variable "abc" with %lastError/pipeline/abc%)
The message for ServiceException can be accessed from lastError/error.
The java service that throws ServiceException is simply like this:
IDataCursor cursor = pipeline.getCursor();
String message = IDataUtil.getString(cursor, "message");
throw new ServiceException(message);
Input:
-message (type: string)
#webMethods#Flow-and-Java-services#Integration-Server-and-ESB