Hi Everyone,

I'm experimenting with servicemix(3.3)+camel(2.2)+cxf (rather new to them)
for implementing a WS client.
I have the following code:

        from("direct:remotesender")
            //.handleFault() 
            .onException(SoapFault.class)
//org.apache.cxf.binding.soap.SoapFault 
                .maximumRedeliveries(0)
                .process(new Processor() { 
                    public void process(Exchange exchange) throws Exception
{
                        log1.info("INBODY
----------------"+exchange.getIn().getBody(String.class));
                        log1.info("INHEAD
----------------"+exchange.getIn().getHeaders());
                        log1.info("OUTBODY
---------------"+exchange.getOut().getBody(String.class));
                        log1.info("OUTHEAD
---------------"+exchange.getOut().getHeaders());
                        log1.info("EXC
-------------------"+exchange.getException());
                        log1.info("FAIL
------------------"+exchange.isFailed());
                        log1.info("EXCP
------------------"+exchange.getProperty(Exchange.EXCEPTION_CAUGHT,
Exception.class));
                        SoapFault faultex =
exchange.getProperty(Exchange.EXCEPTION_CAUGHT, SoapFault.class); 
                        log1.info("NODE
------------------"+faultex.getNode());
                        log1.info("REASON
------------------"+faultex.getReason());
                        log1.info("MSG   
------------------"+faultex.getMessage());
                        log1.info("DETAIL
------------------"+faultex.getDetail());
                    }
                })              
                .end()             
            .process(new Processor() { 
                public void process(Exchange exchange) throws Exception {
                    List<Element> outElements = new ArrayList<Element>(); 
                   
outElements.add(exchange.getIn().getBody(org.w3c.dom.Document.class).getDocumentElement());
                    CxfPayload<SoapHeader> cxfPayload = new
CxfPayload<SoapHeader>(null, outElements);
                    exchange.getOut().setBody(cxfPayload); 
                    log1.info("CFXP VVVVVVVVVVVVVVV"+cxfPayload.toString());
                }
            })
            .setHeader("SOAPAction",
constant("http://service.com/fault_ticket";))
            .to("cxf:bean:serviceEndpoint") // PAYLOAD mode is set from
spring
            .process(new Processor() { 
                public void process(Exchange exchange) throws Exception {
                    log1.info("CCFX VVVVVVVVVVVVVVV");
                    CxfPayload<SoapHeader> requestPayload =
exchange.getIn().getBody(CxfPayload.class);
                    List<Element> inElements = requestPayload.getBody();
                    exchange.getOut().setBody(inElements.get(0)); 
                    log1.info("CFXE
VVVVVVVVVVVVVVV"+exchange.getOut().getBody(String.class));
                }
            })
            ;



1. My primary concern is, that in the case the server returns a SOAPFault, I
can not extract the details of the fault. The SoapFault is thrown, and the
corresponding onException clause is triggered, but according to the log
below, the detail attribute is null.


    11:03:44,210 | INFO  | INBODY
----------------org.apache.camel.component.cxf.CxfPayload     headers:
nullbody: [[REQUEST: null]]
    11:03:44,210 | INFO  | INHEAD
----------------{http://service.com/fault_ticket, CamelRedeliveryCounter=0,
CamelRedelivered=false}
    11:03:44,213 | INFO  | OUTBODY ---------------null
    11:03:44,213 | INFO  | OUTHEAD ---------------{}
    11:03:44,213 | INFO  | EXC -------------------null
    11:03:44,213 | INFO  | FAIL ------------------false
    11:03:44,214 | INFO  | EXCP
------------------org.apache.cxf.binding.soap.SoapFault: Server Error
    11:03:44,214 | INFO  | NODE ------------------null
    11:03:44,214 | INFO  | REASON ------------------Server Error
    11:03:44,214 | INFO  | MSG    ------------------Server Error
    11:03:44,214 | INFO  | DETAIL ------------------[detail: null]


The actual soap response is:

    500 Internal Server Error
    Server: MX/WEBSERVICE 3.X
    Cache-Control: private, pre-check=0, post-check=0, max-age=0
    Pragma: no-cache
    Expires: 0
    Connection: close
    Content-Length: 1551
    Content-Type: text/xml; charset=UTF-8

    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
      <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
          <faultcode>SOAP-ENV:Server</faultcode>
          <faultstring>Server Error</faultstring>
          <detail>
            <e:exception
xmlns:e="http://service.com/interfaces/mx_exception/";>
              <code></code>
              <message>"WORK_ORDER_ALREADY_EXISTS</message>
              <callstack>"POISON_CALL_STACK" .... </callstack>
            </e:exception>
          </detail>
        </SOAP-ENV:Fault>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

2. A second remark is, that the handleFault()  does not seem to have any
effect on the flow. The SoapFault is thrown regardless of it. I expected it
to work similar to jbi faults: when it is present throw the exception,
otherwise just set the EXCEPTION_CAUGHT property on the exchange, and let
the flow continue.

3. My third question, isn't there a simple way to send a SOAP message with
CXF? I mean I have the SOAPBody prepared (as string or
org.w3c.dom.Document), and I expect cxf to wrap it in an envelope, and also
return a SOAPBody. Do I really have to do the cumbersome payload conversions
prior and after the request?


Thanks for your time,
attilav
-- 
View this message in context: 
http://old.nabble.com/How-to-extract-SOAPFault-details-from-CXF-tp28739489p28739489.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to