3 Replies Latest reply on Mar 17, 2012 5:28 AM by Claus Ibsen

    Camel- CXF - Error Handling

    Gautham Rajanna Newbie



      Currently I am using onException as my error handler mechanism.

      I am facing problem in extracting the information in onException section as an object. Rite now I am receiving the entire soap message here since i have used useOriginalMessage set as true.

      My current requirement is to extract the body to an object and map in to an other error object and send the msg as an xml to the queue and send soap fault back to the client.


      Kindly let me know as to how i can proceed from here wherein which processors i have to use.






        • 1. Re: Camel- CXF - Error Handling
          Claus Ibsen Master

          You can transform the message before sending to the JMS queue. And then afterwards transform the message to the fault message.


          For example add a  for that.

          • 2. Re: Camel- CXF - Error Handling
            Gautham Rajanna Newbie



            Thanks for reply. I was able to transform accordingly to send to queue, but i am facing issues in setting the fault response.

            I am actually invoking a bean implementing the exchange wherein I am trying to create a SOAPMessage.

            I found an example for the same in : http://camel.apache.org/cxf-example.html

            But I am finding it diffuclt to convert the exchanges's in body to a SOAPMessage i.e by the following:

            SOAPMessage soapMessage = (SOAPMessage)exchange.getIn().getBody(List.class).get(0);

            This is actually returning me a null but when i print out the exchange i can see the entire SOAP message.


            So please help me out here, Am i doing anything wrong in the conversion?

            Aslo I have an question, the exchange coming out of an cxf endpoint is of camel exchange message or of cxf exchange message? And is there any way I can convert from one to the other?




            • 3. Re: Camel- CXF - Error Handling
              Claus Ibsen Master

              Just get the plain body, and then work your way from there, what it really is


              Object body = exchange.getIn().getBody();


              And when you say printing a the message you can see the soap message? What do you see? XML data? If so that may be because the object has a toString method that prints it nicely in XML, or that the message is just plain XML etc.