如何使用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
中看到SOAP调用详细信息。
流程的相关部分如下所示:
<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"/>
答案 0 :(得分:1)
日志记录拦截器可用于记录来自CXF客户端的入站和出站邮件。
<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" />
希望这有帮助。
答案 1 :(得分: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]
并根据需要使用它。
这项技术非常有用,我几乎在所有流程中都做了,不管它有肥皂入站还是其他原始有效载荷永远不会无法进入