0

I'm using JBoss SOA-P 5.2, which should be equivalent to JBoss ESB 4.10. And our ESB service uses a Http Gateway, which listens request from a web site.

The happy-path is all good: we can return a JSON response to web site application according to the HttpRequest. The problem comes from the exceptional path, where java code throws some exception from the action pipeline. Is there a way that we can catch exception generated in the action pipeline and customized the returned message to web application?

Thanks a lot!

4

2 に答える 2

0

It's suggested by RedHat that we can use RestEasy to accept HTTP requests and invoice ESB service through ServiceInvoker.

于 2012-05-16T00:04:26.253 に答える
0

The message can be setted in the fault exception message. (ActionProcessingFaultException)

Ex:

    public Message process(Message message) throws ActionProcessingException {
    try {
        Object obj = payloadProxy.getPayload(message);
        String value = "";
        if(obj instanceof String) {
            value = (String) obj;
        } else if(obj instanceof byte[]) {
            value = new String((byte[])obj);
        }
        RouteRequest req = gson.fromJson(value, RouteRequest.class);
        if(req == null) {
            logger.warn("Invalid JSON Request to Solve Service. "+value);
            throw new ActionProcessingException("Invalid JSON Request to Solve Service.");
        }
        payloadProxy.setPayload(message, req);
    } catch (MessageDeliverException e) {
        logger.error("Error handling with payload", e);
        throw new ActionProcessingException("Error handling with payload", e);
    } catch (Exception e) {
        String htmlHelp = "<html><body><h1>Bad Format</h1></body></html>";
        message.getBody().add(htmlHelp);
        throw new ActionProcessingFaultException(message, "Error converting Json Object.");
    }

    return message;
}
于 2012-08-23T17:40:04.500 に答える