title: Mule ESB CXF exception handeling
body: <p>I'm using the following XML in mule communication using jaxws-client inside http outbound flow (POJO is the output from outbound Jaxws Client).</p>
  
  <p>for sure generating WS code using wsdl2java plugin in maven , the generated code has class for exception coming from WS the class is :</p>
  
  <p>com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException</p>
  
  <p>for sure http response is 500 when we got SOAPFault after the WS raised this exception </p>
  
  <pre><code>com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException
  
  INFO  2012-11-08 11:08:08,008 [[cxf].TCP_C_L.receiver.02] org.mule.transport.http.HttpClientMessageDispatcher: Received a redirect, but followRedirects=false. Response code: 500 Server Error
  ERROR 2012-11-08 11:08:13,008 [[cxf].TCP_C_L.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy: 
  ********************************************************************************
  Message               : error. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: PostMethod
  Code                  : MULE_ERROR--2
  --------------------------------------------------------------------------------
  Exception stack is:
  1. error (com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException)
    sun.reflect.NativeConstructorAccessorImpl:-2 (null)
  2. error. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of type: PostMethod (org.mule.api.transport.DispatchException)
    org.mule.module.cxf.CxfOutboundMessageProcessor:148 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
  --------------------------------------------------------------------------------
  Root Exception stack trace:
  com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException: error
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
  ********************************************************************************
  
  INFO  2012-11-08 11:08:13,009 [[cxf].TCP_C_L.receiver.02] org.mule.api.processor.LoggerMessageProcessor: org.apache.commons.httpclient.methods.PostMethod@d02649
  INFO  2012-11-08 11:08:13,010 [[cxf].TCP_C_L.receiver.02] org.mule.api.processor.LoggerMessageProcessor: org.apache.commons.httpclient.methods.PostMethod@d02649
  </code></pre>
  
  <p>I'm getting the above error when handeling excpetion using :</p>
  
  <pre><code>&lt;catch-exception-strategy&gt;
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
              &lt;transformer ref="ByteArrayToString" /&gt;
              &lt;append-string-transformer message="&amp;#xD;&amp;#xA;" /&gt;
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
          &lt;/catch-exception-strategy&gt;
  </code></pre>
  
  <p>for sure I need to handle the exception same as apache camel , I need to specify to mule the exception and mule should not raised the above exception in the console as it would be handled by XML configuration .</p>
  
  <p>the type of the incoming messages from jaxWs-client outbound is </p>
  
  <p>org.apache.commons.httpclient.methods.PostMethod@d02649</p>
  
  <p>How can i manage to make Mule ESB understand the WS exception , I tried this </p>
  
  <p></p>
  
  <p>and it didnt work as well .</p>
  
  <p>Can you please advise .</p>
  
  <p>in Fuse ESB i did it like this :</p>
  
  <pre><code>&lt;onException&gt;
  &lt;exception&gt;com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException&lt;/exception&gt;  
              &lt;handled&gt;
                  &lt;constant&gt;true&lt;/constant&gt;
              &lt;/handled&gt;
              &lt;to uri="log:test" /&gt;
              &lt;setBody&gt;
  
                  &lt;simple&gt;${exception.getFaultInfo}&lt;/simple&gt;
  
              &lt;/setBody&gt;
              &lt;to uri="log:exception" /&gt;
              &lt;convertBodyTo      type="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1.FaultMessage" /&gt;
              &lt;marshal ref="decExc" /&gt;
              &lt;convertBodyTo type="String" /&gt;
              &lt;bean ref="nulladd" /&gt;
          &lt;/onException&gt;
  </code></pre>
  
  <p>how can i make the same in Mule ESB .</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:file="http://www.mulesoft.org/schema/mule/file"
      xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp"
      xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
      xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
      xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
      xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="EE-3.3.0"
      xmlns:script="http://www.mulesoft.org/schema/mule/scripting"
      xsi:schemaLocation="
  http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd 
  http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd 
  http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd 
  http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/3.2/mule-scripting.xsd
  http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd 
  http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd 
  http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd 
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd 
  http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd 
  http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd "&gt;
      &lt;spring:beans&gt;
          &lt;spring:bean name="samlCallbackHandler"
              class="com.mulesoft.mule.example.security.SAMLCallbackHandler" id="samlCallbackHandler" /&gt;
      &lt;/spring:beans&gt;
  
  
  
  
      &lt;sub-flow name="Jaxws" doc:name="Jaxws"&gt;
          &lt;cxf:jaxws-client operation="ExecuteCommand"
              serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface"
              doc:name="UsernameToken SOAP client"&gt;
              &lt;!-- &lt;cxf:ws-security&gt; &lt;cxf:ws-config&gt; &lt;cxf:property key="action" value="UsernameToken 
                  Timestamp" /&gt; &lt;cxf:property key="user" value="joe" /&gt; &lt;cxf:property key="passwordCallbackClass" 
                  value="com.mulesoft.mule.example.security.PasswordCallback" /&gt; &lt;cxf:property 
                  key="mustUnderstand" value="false" /&gt; &lt;/cxf:ws-config&gt; &lt;/cxf:ws-security&gt; --&gt;
          &lt;/cxf:jaxws-client&gt;
      &lt;/sub-flow&gt;
  
      &lt;sub-flow name="usernameToken1" doc:name="usernameToken1"&gt;
          &lt;!-- &lt;cxf:jaxws-client operation="ExecuteCommand" serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface" 
              doc:name="UsernameToken SOAP client"&gt; &lt;cxf:ws-security&gt; &lt;cxf:ws-config&gt; &lt;cxf:property 
              key="action" value="UsernameToken Timestamp" /&gt; &lt;cxf:property key="user" 
              value="joe" /&gt; &lt;cxf:property key="passwordCallbackClass" value="com.mulesoft.mule.example.security.PasswordCallback" 
              /&gt; &lt;cxf:property key="mustUnderstand" value="false" /&gt; &lt;/cxf:ws-config&gt; &lt;/cxf:ws-security&gt; 
              &lt;/cxf:jaxws-client&gt; --&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="8899" path="cxf/services"
              doc:name="Invoke NSNusernameToken Web Service"&gt;
              &lt;cxf:jaxws-client operation="ExecuteCommand"
                  serviceClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisInterface"
                  doc:name="UsernameToken SOAP client"&gt;
                  &lt;cxf:ws-security&gt;
                      &lt;cxf:ws-config&gt;
                          &lt;cxf:property key="action" value="UsernameToken Timestamp" /&gt;
                          &lt;cxf:property key="user" value="joe" /&gt;
                          &lt;cxf:property key="passwordCallbackClass"
                              value="com.mulesoft.mule.example.security.PasswordCallback" /&gt;
                          &lt;cxf:property key="mustUnderstand" value="false" /&gt;
                      &lt;/cxf:ws-config&gt;
                  &lt;/cxf:ws-security&gt;
                  &lt;cxf:inInterceptors /&gt;
                  &lt;cxf:outInterceptors /&gt;
  
  
  
              &lt;/cxf:jaxws-client&gt;
  
  
  
  
          &lt;/http:outbound-endpoint&gt;
  
  
  
  
  
          &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
  
          &lt;mulexml:jaxb-object-to-xml-transformer
              jaxbContext-ref="xmltoobj" /&gt;
          &lt;object-to-string-transformer /&gt;
          &lt;append-string-transformer message="&amp;#xD;&amp;#xA;" /&gt;
  
          &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
  
      &lt;/sub-flow&gt;
      &lt;object-to-string-transformer name="ObjectToString" /&gt;
      &lt;byte-array-to-string-transformer
          name="ByteArrayToString" /&gt;
  
  
  
      &lt;tcp:connector name="TCP_C_L" validateConnections="false"
          receiveBufferSize="102400" sendBufferSize="102400" doc:name="TCP"&gt;
          &lt;tcp:xml-protocol /&gt;
      &lt;/tcp:connector&gt;
  
  
  
      &lt;mulexml:jaxb-context name="myJaxbContext"
          packageNames="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1" /&gt;
  
  
  
  
  
      &lt;mulexml:jaxb-context name="xmltoobj"
          packageNames="com.nsn.ossbss.charge_once.wsdl.entity.tis.xsd._1" /&gt;
  
  
      &lt;flow name="NSNServiceClient" doc:name="NSN IN Unified Client Service"&gt;
          &lt;tcp:inbound-endpoint host="localhost" port="51000"
              connector-ref="TCP_C_L" /&gt;
          &lt;transformer ref="ByteArrayToString" /&gt;
  
          &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
          &lt;mulexml:jaxb-xml-to-object-transformer
              jaxbContext-ref="myJaxbContext" /&gt;
  
          &lt;flow-ref name="usernameToken1" doc:name="usernameToken1" /&gt;
  
          &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
  
          &lt;!-- &lt;default-exception-strategy&gt; &lt;choice&gt; 
          &lt;when evaluator="groovy" expression='payload.getException().getClass().getName().equals("com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException")'&gt; 
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt; &lt;object-to-string-transformer/&gt; 
              &lt;append-string-transformer message="&amp;#xD;&amp;#xA;" /&gt; &lt;vm:outbound-endpoint 
              path="error.notification"/&gt; &lt;/when&gt; &lt;/choice&gt; &lt;/default-exception-strategy&gt; --&gt;
  
  
  
          &lt;catch-exception-strategy&gt;
  
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
  
              &lt;transformer ref="ByteArrayToString" /&gt;
  
  
              &lt;append-string-transformer message="&amp;#xD;&amp;#xA;" /&gt;
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt;
  
  
  
  
          &lt;/catch-exception-strategy&gt;
  
  
  
  
          &lt;!-- &lt;auto-transformer returnClass="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException"/&gt; --&gt;
  
  
  
  
  
  
          &lt;!-- &lt;custom-exception-strategy class="com.nsn.ossbss.charge_once.wsdl.entity.tis.wsdl._1.TisException"&gt; 
              &lt;logger message="#[payload]" level="INFO" doc:name="Logger" /&gt; &lt;/custom-exception-strategy&gt; --&gt;
  
      &lt;/flow&gt;
  
  
  
  
      &lt;flow name="SecurityClients" doc:name="SecurityClients"&gt;
          &lt;http:inbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63080" path="client" doc:name="HTTP Inbound Endpoint" /&gt;
          &lt;set-payload
              value="#[message.inboundProperties['http.query.params']['name']]"
              doc:name="Set payload with 'name' query param" /&gt;
          &lt;set-variable variableName="clientType"
              value="#[message.inboundProperties['http.query.params']['clientType']]"
              doc:name="Set clientType" /&gt;
          &lt;choice doc:name="Choice"&gt;
              &lt;when expression="#[clientType == 'unsecure']"&gt;
                  &lt;processor-chain&gt;
                      &lt;flow-ref name="unsecure" doc:name="Invoke unsecure sub-flow" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/when&gt;
              &lt;!--&lt;when expression="#[clientType == 'usernameToken']"&gt; &lt;processor-chain&gt; 
                  &lt;flow-ref name="usernameToken1" doc:name="usernameToken1" /&gt; &lt;/processor-chain&gt; 
                  &lt;/when&gt; --&gt;
              &lt;when expression="#[clientType == 'usernameTokenSigned']"&gt;
                  &lt;processor-chain&gt;
                      &lt;flow-ref name="usernameTokenSigned" doc:name="Invoke usernameToken Signed sub-flow" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/when&gt;
              &lt;when expression="#[clientType == 'usernameTokenEncrypted']"&gt;
                  &lt;processor-chain&gt;
                      &lt;flow-ref name="usernameTokenEncrypted" doc:name="Invoke usernameToken Encrypted sub-flow" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/when&gt;
              &lt;when expression="#[clientType == 'samlToken']"&gt;
                  &lt;processor-chain&gt;
                      &lt;flow-ref name="samlToken" doc:name="Invoke samlToken sub-flow" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/when&gt;
              &lt;when expression="#[clientType == 'samlTokenSigned']"&gt;
                  &lt;processor-chain&gt;
                      &lt;flow-ref name="samlTokenSigned" doc:name="Invoke samlToken Signed sub-flow" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/when&gt;
              &lt;otherwise&gt;
                  &lt;processor-chain&gt;
                      &lt;set-payload value="Client type is not supported"
                          doc:name="Client type is not supported" /&gt;
                  &lt;/processor-chain&gt;
              &lt;/otherwise&gt;
          &lt;/choice&gt;
          &lt;set-property propertyName="Content-Type" value="text/plain"
              doc:name="Set response Content-Type" /&gt;
          &lt;catch-exception-strategy doc:name="Catch Exception Strategy"&gt;
              &lt;set-payload value="There has been an Error processing the request"
                  doc:name="Set Payload" /&gt;
              &lt;set-property propertyName="Content-Type" value="text/plain"
                  doc:name="Set response Content-Type" /&gt;
          &lt;/catch-exception-strategy&gt;
  
  
  
      &lt;/flow&gt;
      &lt;sub-flow name="unsecure" doc:name="unsecure"&gt;
          &lt;cxf:jaxws-client operation="greet"
              serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="Unsecure SOAP client"
              doc:description="Unsecure SOAP client" /&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63081" path="services/unsecure" doc:name="Invoke unsecure Web Service" /&gt;
      &lt;/sub-flow&gt;
      &lt;!-- &lt;sub-flow name="usernameToken" doc:name="usernameToken"&gt; &lt;cxf:jaxws-client 
          operation="greet" serviceClass="com.mulesoft.mule.example.security.Greeter" 
          doc:name="UsernameToken SOAP client"&gt; &lt;cxf:ws-security&gt; &lt;cxf:ws-config&gt; &lt;cxf:property 
          key="action" value="UsernameToken Timestamp"/&gt; &lt;cxf:property key="user" value="joe"/&gt; 
          &lt;cxf:property key="passwordCallbackClass" value="com.mulesoft.mule.example.security.PasswordCallback"/&gt; 
          &lt;/cxf:ws-config&gt; &lt;/cxf:ws-security&gt; &lt;/cxf:jaxws-client&gt; &lt;http:outbound-endpoint 
          exchange-pattern="request-response" host="localhost" port="63081" path="services/username" 
          doc:name="Invoke usernameToken Web Service"/&gt; &lt;/sub-flow&gt; --&gt;
      &lt;sub-flow name="usernameTokenSigned" doc:name="usernameTokenSigned"&gt;
          &lt;cxf:jaxws-client operation="greet"
              serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="UsernameToken Signed SOAP client"&gt;
              &lt;cxf:ws-security&gt;
                  &lt;cxf:ws-config&gt;
                      &lt;cxf:property key="action" value="UsernameToken Signature Timestamp" /&gt;
                      &lt;cxf:property key="signaturePropFile" value="wssecurity.properties" /&gt;
                      &lt;cxf:property key="user" value="joe" /&gt;
                      &lt;cxf:property key="passwordCallbackClass"
                          value="com.mulesoft.mule.example.security.PasswordCallback" /&gt;
                  &lt;/cxf:ws-config&gt;
              &lt;/cxf:ws-security&gt;
          &lt;/cxf:jaxws-client&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63081" path="services/signed"
              doc:name="Invoke usernameToken Signed Web Service" /&gt;
      &lt;/sub-flow&gt;
      &lt;sub-flow name="usernameTokenEncrypted" doc:name="usernameTokenEncrypted"&gt;
          &lt;cxf:jaxws-client operation="greet"
              serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="UsernameToken Encrypted SOAP client"&gt;
              &lt;cxf:ws-security&gt;
                  &lt;cxf:ws-config&gt;
                      &lt;cxf:property key="action" value="UsernameToken Timestamp Encrypt" /&gt;
                      &lt;cxf:property key="encryptionPropFile" value="wssecurity.properties" /&gt;
                      &lt;cxf:property key="user" value="joe" /&gt;
                      &lt;cxf:property key="encryptionUser" value="joe" /&gt;
                      &lt;cxf:property key="passwordCallbackClass"
                          value="com.mulesoft.mule.example.security.PasswordCallback" /&gt;
                  &lt;/cxf:ws-config&gt;
              &lt;/cxf:ws-security&gt;
          &lt;/cxf:jaxws-client&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63081" path="services/encrypted"
              doc:name="Invoke usernameToken Encrypted Web Service" /&gt;
      &lt;/sub-flow&gt;
      &lt;sub-flow name="samlToken" doc:name="samlToken"&gt;
          &lt;cxf:jaxws-client operation="greet"
              serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="SAMLToken SOAP client"&gt;
              &lt;cxf:ws-security&gt;
                  &lt;cxf:ws-config&gt;
                      &lt;cxf:property key="action" value="SAMLTokenUnsigned Timestamp" /&gt;
                      &lt;cxf:property key="samlPropFile" value="saml.properties" /&gt;
                      &lt;cxf:property key="samlCallbackClass"
                          value="com.mulesoft.mule.example.security.SAMLCallbackHandler" /&gt;
                  &lt;/cxf:ws-config&gt;
              &lt;/cxf:ws-security&gt;
          &lt;/cxf:jaxws-client&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63081" path="services/saml" doc:name="Invoke SAMLToken Web Service" /&gt;
      &lt;/sub-flow&gt;
      &lt;sub-flow name="samlTokenSigned" doc:name="samlTokenSigned"&gt;
          &lt;cxf:jaxws-client operation="greet"
              serviceClass="com.mulesoft.mule.example.security.Greeter" doc:name="SAMLToken Signed SOAP client"&gt;
              &lt;cxf:ws-security&gt;
                  &lt;cxf:ws-config&gt;
                      &lt;cxf:property key="action" value="SAMLTokenSigned" /&gt;
                      &lt;cxf:property key="samlPropFile" value="saml.properties" /&gt;
                      &lt;cxf:property key="signatureKeyIdentifier" value="DirectReference" /&gt;
                      &lt;cxf:property key="user" value="joe" /&gt;
                      &lt;cxf:property key="passwordCallbackClass"
                          value="com.mulesoft.mule.example.security.PasswordCallback" /&gt;
                      &lt;cxf:property key="samlCallbackClass"
                          value="com.mulesoft.mule.example.security.SAMLCallbackHandler" /&gt;
                  &lt;/cxf:ws-config&gt;
              &lt;/cxf:ws-security&gt;
          &lt;/cxf:jaxws-client&gt;
          &lt;http:outbound-endpoint exchange-pattern="request-response"
              host="localhost" port="63081" path="services/signedsaml"
              doc:name="Invoke SAMLToken Signed Web Service" /&gt;
      &lt;/sub-flow&gt;
  
  &lt;/mule&gt;
  </code></pre>
  
  <p>The first sub flow usernameToken1 is calling the Web service which i deployed on apache camel , I just mentioned in the question above the exception class which has been raised.</p>
  
  <p>Kindly let me know your feedback,</p>