Camel does not intercept SoapFault with camel-cxf correctly

I need help. I cannot get the exception that my web service is throwing and I don't know why.

I created a simple camel route and I want to get infected with error messages from a web service as an exception with an explanation of the error.

The route is as follows:

    onException(Exception.class)
        .handled(true)
        .to("log:info")
        .process(new FailureResponseProcessor())
        .to("file:data/outbox?fileName=error.xml");

    from("file:data/inbox?noop=true")   
        .process(loggerProcessor)
        .to("cxf://http://localhost:8080/TestWebService?dataFormat=PAYLOAD"
          + "&properties.exceptionMessageCauseEnabled=true"
          + "&properties.faultStackTraceEnabled=true")
        .to("file:data/outbox?fileName=response.xml");

      

In the context configuration, I have this:

context.setHandleFault(true);

      

The webservice I created for testing is simple like this:

@WebService
public class TestWebService {
    @WebMethod
    public double suma(double a, double b) throws Exception {
        System.out.println("Webservice invocado!!!");
        throw new Exception("Mi excepcion");
        //return a + b;
    }
}

      

But I cannot get the message from the "Mi excepcion" exception.

I guess the problem is coming from this line:

2015-04-28 13:05:15 DEBUG DefaultErrorHandler:71 - Failed delivery for (MessageId: ID-saqqara-40731-1430219108400-0-3 on ExchangeId: ID-saqqara-40731-1430219108400-0-2). On delivery attempt: 0 caught: org.apache.cxf.binding.soap.SoapFault: No se ha encontrado el método de distribución de {http://schemas.xmlsoap.org/soap/envelope/}Envelope

      

Because the catch exception is my exception policy:

Error: No se ha encontrado el método de distribución de {http://schemas.xmlsoap.org/soap/envelope/}Envelope

      

EDIT:

I modified the code a bit to record additional information. This is what I did:

onException(SoapFault.class)
    .handled(true)
    .log("Response ON ERROR: ${body}")
    .log("Response ON FAULT: ${exception}")
    .process(new FailureResponseProcessor())
    .to("file:data/outbox?fileName=error.xml");

from("file:data/inbox?noop=true")
    .id("miRuta")
    .log("File content: ${body}")
    .to("cxf://http://localhost:8080/TestWebService?dataFormat=PAYLOAD"
      + "&properties.exceptionMessageCauseEnabled=true"
      + "&properties.faultStackTraceEnabled=true")
    .log("WS Response: ${body}");

      

I found that when an exception is caught, a message that is logged with the following line:

.log("Response ON ERROR: ${body}")

      

- this is:

2015-04-29 09:53:28 INFO  route1:95 - Response ON ERROR:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:test="http://test_ws.testing.com/">
    <soapenv:Header/>
    <soapenv:Body>
        <test:suma>
           <arg0>?</arg0>
           <arg1>?</arg1>
        </test:suma>
    </soapenv:Body>
</soapenv:Envelope>

      

If this is a malfunction message, right?

EDIT 2

The XML response is as follows:

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
            <faultcode>S:Server</faultcode>
            <faultstring>Mi excepcion</faultstring>
            <detail>
                <ns2:Exception xmlns:ns2="http://test_ws.testing.com/">
                    <message>Mi excepcion</message>
                </ns2:Exception>
            </detail>
        </S:Fault>
    </S:Body>
</S:Envelope>

      

+3


source to share


1 answer


Finally I found the problem.

xml file I was catching:

from("file:data/inbox?noop=true")

      

Has the following content:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://test_ws.testing.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <test:suma>
         <arg0>5</arg0>
         <arg1>5</arg1>
      </test:suma>
   </soapenv:Body>
</soapenv:Envelope>

      



The error was generated correctly by the testing web service, but another stating that the Envelope method was not found, which is correct because the Envelop method does not exist in the web service. The method that exists is "suma".

So, I changed the xml to the following:

<test:suma xmlns:test="http://test_ws.testing.com/">
  <arg0>5</arg0>
  <arg1>5</arg1>
</test:suma>

      

And I got the expected exception: "Mi excepcion".

Thanks for your help anyway !!

0


source







All Articles