camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yuncil <jonas.stei...@hotmail.de>
Subject create SOAP-Fault with exception message included
Date Tue, 20 May 2014 14:57:39 GMT
Hi,

in my camel-route i want to send a soap-fault as response in case of
exception. My Problem is i don't know how to create a SOAP-Fault using the
SOAPJaxbDataFormat. Currently i use this code:

private class ExceptionResponse implements Processor {

        @Override
        public void process(Exchange exchange) throws Exception {


        //Jaxbclass with 3 elements
        MyResponse response = new MyResponse();

            try {

                Throwable caused =
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Throwable.class);
                
                response.setMessage(caused.getMessage());
                response.setRequestId("12345");
                response.setResultCode("200");
               
                SoapJaxbDataFormat soap = new
SoapJaxbDataFormat("my.context.path");
               
                OutputStream out = new ByteArrayOutputStream();
               
                soap.marshal(exchange, response, out);
               
                logger.info("SOAP-MSG: " + out.toString());
            }
            catch (Exception e) {
                logger.error("Fehler beim Erstellen der SOAP-Nachricht", e);
            }
            exchange.getOut().setBody(response, MyResponse.class);
        }

Unfortenetly i get a java.lang.NullPointerException here:
soap.marshal(exchange, response, out);

I also don't know how to set the fault-element in a SOAP-Response. 

Anyone an idea? Thanks in advance



--
View this message in context: http://camel.465427.n5.nabble.com/create-SOAP-Fault-with-exception-message-included-tp5751358.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message