0

如何使用 Mule 3.3.1 记录原始 SOAP 异常响应?当我<exception-strategy ref="myStrategy"/>在流程的末尾添加一个并myStrategy定义如下时:

<choice-exception-strategy name="myStrategy">
    <catch-exception-strategy when="exception.causedBy(com.example.ServiceException)">
        <logger message="Caught a service exception" level="INFO" />
        <!-- <logger message="what to put here to get SOAP response?" level="INFO"/> -->
    </catch-exception-strategy>
    <catch-exception-strategy doc:name="Catch Exception Strategy">
        <logger level="INFO" doc:name="Logger"/>
    </catch-exception-strategy>
</choice-exception-strategy>

我希望能够输出原始 SOAP 响应。

消息有效负载似乎属于该payload=org.apache.commons.httpclient.methods.PostMethod类型。我可以在 OUTBOUND scoped properties.

流程的相关部分如下所示:

<https:outbound-endpoint exchange-pattern="request-response" host="hostAddress" port="portNumber" path="path/to/service" doc:name="HTTP" connector-ref="connector" responseTimeout="50000" >
    <cxf:jaxws-client clientClass="com.example.Service"
    enableMuleSoapHeaders="true" doc:name="SOAP" operation="methodName"
    port="PortName"
    wsdlLocation="wsdl/wsdlName.wsdl">
    </cxf:jaxws-client>
</https:outbound-endpoint>
<exception-strategy ref="myStrategy" doc:name="Reference Exception Strategy"/>
4

2 回答 2

1

获取原始有效负载的最佳方法<catch-exception-strategy>是将原始有效负载存储在一个变量中,作为流中的第一件事,然后在异常块中访问它。

<https:outbound-endpoint exchange-pattern="request-response" host="hostAddress" port="portNumber" path="path/to/service" doc:name="HTTP" connector-ref="connector" responseTimeout="50000" >
    <cxf:jaxws-client clientClass="com.example.Service"
    enableMuleSoapHeaders="true" doc:name="SOAP" operation="methodName"
    port="PortName"
    wsdlLocation="wsdl/wsdlName.wsdl">
    </cxf:jaxws-client>
</https:outbound-endpoint>

<xm:dom-to-xml-transformer/>
<set-variable variableName="originalPayload" value="#[payload]" />

<exception-strategy ref="myStrategy" doc:name="Reference Exception Strategy"/>

然后在您的 中<catch-exception-strategy>,执行以下操作:<set-payload value="originalPayload"/>或访问有效负载#[originalPayload]并根据需要使用它。

这种技术非常有用,我几乎在所有流程中都这样做,无论它是否有肥皂入站或其他,原始有效负载将永远无法访问

于 2013-10-24T13:18:20.207 回答
1

Logging Interceptors can be used to log the Inbound and Outbound messages from a CXF client.

<cxf:inInterceptors>
     <spring:ref bean="cxfLoggingInInterceptor" />
</cxf:inInterceptors> 
<cxf:outInterceptors>
    <spring:ref bean="cxfLoggingOutInterceptor" />
</cxf:outInterceptors>


<bean id="cxfLoggingInInterceptor"  class="org.apache.cxf.interceptor.LoggingInInterceptor" />
<bean id="cxfLoggingOutInterceptor"  class="org.apache.cxf.interceptor.LoggingOutInterceptor" />

Hope this helps.

于 2013-10-24T13:03:37.190 回答