当我在子流程中使用HTTP出站端点(Mule 3.3.1)时:
<http:outbound-endpoint exchange-pattern="request-response" host="www.myhost.com" port="80" path="SOMESERVICE.asmx?wsdl" contentType="text/xml" method="GET"/>
或
<http:outbound-endpoint exchange-pattern="request-response" address="www.myhost.com:80/SOMESERVICE.asmx?wsdl" contentType="text/xml" method="GET"/>
如果在该路径上找不到服务,我将获得404。这是基于http状态404的流程中的句柄。当流程结束时,我得到这个异常(分三部分,因为StackOverflow的完整堆栈跟踪很长)(仅当路径属性不正确时,对于不正确的主机或port属性没有抛出异常):
第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)
第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)
第3部分:
Caused by: org.mule.transport.http.HttpResponseException: Not Found, code: 404
at org.mule.transport.http.HttpClientMessageDispatcher.doSend(HttpClientMessageDispatcher.java:278)
完整配置:
<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="<dummy/>" 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="<result>OK</result>" doc:name="OK"/>
</when>
<otherwise>
<set-payload value="<result>NotAvailable</result>" doc:name="NotAvailable"/>
</otherwise>
</choice>
</sub-flow>
我的主要流程确实使用了catch-exception-strategy,但这并没有捕获异常。 知道什么可能是错的吗?
干杯,
聪岛
答案 0 :(得分:1)
我在不查看您的配置的情况下猜测您可能已将sub-flow
声明为
<flow>
而不是<sub-flow>
答案 1 :(得分:-1)
HTTP状态&gt; = 400本身不被视为例外。
如果您希望您的异常策略发挥作用,则需要根据HTTP状态代码抛出异常。只需在<flow-ref name="ping"/>
之后添加以下内容:
<message-filter throwOnUnaccepted="true">
<message-property-filter pattern="message.inboundProperties['http.status'] >= 400" />
</message-filter>