Sunday, October 23, 2011

Using Raise Error in OSB

If in your Message Flow you Raise Error:

Raise Error using error code [ MY_ERROR_CODE ] with error Message MY_ERROR_MESSAGE



the error handler will show in the
"errorCode" and "reason" respectively the
"error code and "error message"
that you have provided:

<con:fault xmlns:con="http://www.bea.com/wli/sb/context">
<con:errorCode>MY_ERROR_CODE</con:errorCode>
<con:reason>MY_ERROR_MESSAGE</con:reason>
<con:location>
<con:node>PipelinePairNode1</con:node>
<con:pipeline>PipelinePairNode1_request</con:pipeline>
<con:stage>stage1</con:stage>
<con:path>request-pipeline</con:path>
</con:location>
</con:fault>

both Service Error Handler and System Error Handler are invoked with the same fault, because in my Message Flow, the Service Error Handler doesn't handle the error:


If the Service Error Handler does a "reply with success", the same body as the request is returned in the response.
If the Service Error Handler does a "reply with error", the test console returns a message "The invocation resulted in an error: ."

Analyzing with SOAP UI (I create a Rest service and do a POST), if I show the RAW response I get:

HTTP/1.1 500 Internal Server Error
Date: Sun, 23 Oct 2011 21:45:50 GMT
Content-Length: 61
Content-Type: text/xml; charset=utf-8
X-Powered-By: Servlet/2.5 JSP/2.1

<?xml version="1.0" encoding="UTF-8"?>
<hello>pierre</hello>


in fact "Reply with Error" returns a HTTP 500



see also http://www.javamonamour.org/2011/07/throwing-exceptions-in-xquery-fnerror.html on how to raise an error in XQuery

No comments: