Mule 为什么骡子负载在<;捕获异常策略>;对于java.net.ConnectException

Mule 为什么骡子负载在<;捕获异常策略>;对于java.net.ConnectException,mule,Mule,我正在测试我的Mule(3.3.1)流,它向外部供应商发送web服务调用。我的目标是捕获java.net.ConnectException,并将适当的XSLT应用于原始负载,并将其发送给调用者 但是在中接收到的有效负载属于org.apache.commons.httpclient.methods类型。PostMethod@12b13004而不是原始的XML。尝试使用,但没有帮助 对于如何在catch块中检索原始有效负载有何建议 mule config.xml的一部分如下: <flo

我正在测试我的Mule(3.3.1)流,它向外部供应商发送web服务调用。我的目标是捕获
java.net.ConnectException
,并将适当的
XSLT
应用于原始负载,并将其发送给调用者

但是在
中接收到的有效负载属于
org.apache.commons.httpclient.methods类型。PostMethod@12b13004
而不是原始的
XML
。尝试使用
,但没有帮助

对于如何在
catch
块中检索原始有效负载有何建议

mule config.xml
的一部分如下:

    <flow name="orderRequirementsToVendor">
        <jms:inbound-endpoint queue="order.vendor" />   

        <set-property propertyName="SOAPAction" value="http://vendor.com/services/InterfacePoint/Call" /> 

        <cxf:proxy-client payload="body" enableMuleSoapHeaders="false">
            <cxf:inInterceptors>
                <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor" />                  
            </cxf:inInterceptors>
            <cxf:outInterceptors>
                <spring:bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" />
            </cxf:outInterceptors>
        </cxf:proxy-client>
        <outbound-endpoint address="${vendor.ws.url}" mimeType="text/xml" connector-ref="https.connector" />
        <byte-array-to-string-transformer />

         <choice-exception-strategy>
            <catch-exception-strategy when="#[exception.causedBy(java.net.ConnectException)]">
                <logger message="#[exception.causeException]" level="ERROR" />
                <object-to-string-transformer/>
                <transformer ref="vendorConnectExceptionTransformer" />
             </catch-exception-strategy>
            <catch-exception-strategy>
                <logger message="#[exception.causeException]" level="ERROR" />
                <transformer ref="generalErrorTransformer" />
            </catch-exception-strategy>
        </choice-exception-strategy> 

    </flow> 

  • jms:inbound endpoint
    之后,使用

    <set-variable variableName="originalPayload" value="#[message.payload]" />
    
    
    
  • 使用MEL表达式(如:
    #[flowVars.originalPayload]
    )在异常策略中访问它


  • 是的,这是个好主意。但是为什么有效载荷会丢失呢。我了解到Mule(3.3及以后版本)在抛出异常时保留原始有效负载,并且不会用异常有效负载替换它,事实就是这样:您看到的有效负载不是异常有效负载(位于名为
    exception
    的属性中)但是当故障发生时,有效负载准备由
    出站端点发送。但是没有一种方法可以从准备发送的有效负载中提取xml吗实际上:您可以尝试:有效负载的类型是
    org.apache.commons.httpclient.methods.PostMethod
    ,因此您可以使用
    https://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/methods/EntityEnclosingMethod.html#getRequestEntity%28%29
    到检索其内容。但这种方法的警告是,它将您与HTTP传输的内部联系在一起,我不鼓励您这样做。