0
votes

When I use HTTP outbound endpoint (Mule 3.3.1) like this in my sub flow:

<http:outbound-endpoint exchange-pattern="request-response" host="www.myhost.com" port="80" path="SOMESERVICE.asmx?wsdl" contentType="text/xml" method="GET"/>

or

<http:outbound-endpoint exchange-pattern="request-response" address="www.myhost.com:80/SOMESERVICE.asmx?wsdl" contentType="text/xml" method="GET"/>

I will get a 404 in case of service not found on that path. This is handle in the flow based on the http status 404. When the flow finishes I get this exception (in three parts, because the complete stack trace is to long for StackOverflow) (only when the path attribute is incorrect, for incorrect host or port attributes no exception is thrown):

Part 1:

WARN  2013-04-03 12:02:48,459 [[main].connector.http.mule.default.receiver.02] org.apache.cxf.phase.PhaseInterceptorChain: Application {http://support.cxf.module.mule.org/}ProxyService has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://www.myhost.com:80/SOMESERVICE.asmx?wsdl, connector=HttpConnector
    {
      name=connector.http.mule.default
      lifecycle=start
      this=6215723d
      numberOfConcurrentTransactedReceivers=4
      createMultipleTransactedReceivers=true
      connected=true
      supportedProtocols=[http]
      serviceOverrides=<none>
    }
    ,  name='endpoint.http.www.myhost.com.80.SOMESERVICE.asmx.wsdl', mep=REQUEST_RESPONSE, properties={wsdl=, http.method=GET}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: GetMethod
        at org.mule.module.cxf.MuleInvoker.invoke(MuleInvoker.java:151)
        at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)

Part 2:

Caused by: org.mule.api.transport.DispatchException: Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://www.myhost.com:80/SOMESERVICE.asmx?wsdl, connector=HttpConnector
{
  name=connector.http.mule.default
  lifecycle=start
  this=6215723d
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
}
,  name='endpoint.http.www.myhost.com.80.SOMESERVICE.asmx.wsdl', mep=REQUEST_RESPONSE, properties={wsdl=, http.method=GET}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: GetMethod
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:278)

Part 3:

Caused by: org.mule.transport.http.HttpResponseException: Not Found, code: 404
    at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:278)

Full configuration:

<flow name="main">
    <http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8181/my-service/v1" doc:name="HTTP"/>
    <cxf:proxy-service doc:name="SOAP" wsdlLocation="classpath:my-1.0.wsdl" 
        namespace="http://myservice.com/wsdl/my-service/1.0" service="myService" payload="envelope"/>
    <logger level="TRACE" doc:name="Payload Logger" category="main" message="Payload: #[payload:java.lang.String]"/>

    <flow-ref name="ping"/>

    <!-- Exception should be catched here. -->
    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <logger message="Exception: #[payload:java.lang.String]" level="ERROR" category="main" doc:name="Logger"/>
        <set-payload value="&lt;dummy/&gt;" doc:name="Reset Payload"/>
        <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="exception-response.xslt" doc:name="Exception Transformer">
            <mulexml:context-property key="faultString" value="Unexpected Exception"/>
            <mulexml:context-property key="errorCode" value="-1"/>
            <mulexml:context-property key="errorMessage" value="Unexpected Exception."/>
        </mulexml:xslt-transformer>
    </catch-exception-strategy>
</flow>

<sub-flow name="ping">
    <logger message="Request payload: #[payload:java.lang.String]" level="TRACE" category="ping" doc:name="Logger"/>

    <flow-ref name="http" />

    <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" doc:name="Response Transformation" xsl-file="response.xslt"/>

    <!-- Here the correct response is printed and no exception. -->
    <logger message="Response payload after transformation: #[payload:java.lang.String]" level="TRACE" category="ping" doc:name="Logger"/>
</sub-flow>

<sub-flow name="http">
    <logger message="Request payload: #[payload:java.lang.String]" level="TRACE" category="http" />

    <http:outbound-endpoint exchange-pattern="request-response" address="www.myhost.com:80/SOMESERVICE.asmx?wsdl" contentType="text/xml" method="GET"/>

    <choice doc:name="Choice">
        <when expression="#[message.inboundProperties['http.status'] == 200]">
            <set-payload value="&lt;result&gt;OK&lt;/result&gt;" doc:name="OK"/>
        </when>
        <otherwise>
            <set-payload value="&lt;result&gt;NotAvailable&lt;/result&gt;" doc:name="NotAvailable"/>
        </otherwise>
    </choice>
</sub-flow>

My main flow does use catch-exception-strategy, but this doesn't catch the exception. Any idea what might be wrong?

Cheers,

Tuno

2
Can you share your full configuration?Seba
Added full configuration.Tuno

2 Answers

1
votes

My guess without looking at your configuration is that you've probably declared sub-flow as <flow> and not as <sub-flow>

-1
votes

An HTTP status >= 400 is not considered as an exception in itself.
If you want your exception strategy to come into play, you would need to throw an exception based on the HTTP status code. Simply add the following after <flow-ref name="ping"/>:

<message-filter throwOnUnaccepted="true">
    <message-property-filter pattern="message.inboundProperties['http.status'] >= 400" />
</message-filter>