You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by yuncil <jo...@hotmail.de> on 2014/05/20 16:57:39 UTC

create SOAP-Fault with exception message included

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.