使用Mule 3.3.1记录原始SOAP异常响应
如何使用Mule 3.3.1记录原始SOAP异常响应?当我在流程的末尾添加一个使用Mule 3.3.1记录原始SOAP异常响应,soap,mule,Soap,Mule,如何使用Mule 3.3.1记录原始SOAP异常响应?当我在流程的末尾添加一个以及定义如下的myStrategy时: <choice-exception-strategy name="myStrategy"> <catch-exception-strategy when="exception.causedBy(com.example.ServiceException)"> <logger message="Caught a service e
以及定义如下的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>
<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"/>
日志侦听器可用于记录来自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" />
希望这有帮助。在
中获取原始有效负载的最佳方法是将原始有效负载存储在变量中,作为流中的第一件事,然后在异常块中访问它
<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"/>
然后在您的
中,执行以下操作:
或作为#[originalPayload]
访问有效负载,并根据需要使用它
这项技术非常有用,我几乎在所有流中都使用它,不管它是否有soap入站或其他,原始有效负载永远不会不可访问您是否从正在进行的出站呼叫中接收到soap错误?还是要捕获异常并给出SOAP错误?我想记录服务的原始响应。我相信我得到了适当的
com.example.ServiceException
。当您从正在调用的服务接收到异常时,将不会记录响应。paylaod包含从流发送的Post请求。如果要返回一个SOAP错误,那么它应该由您在基于异常的异常策略中准备。如果SOAP错误作为您从流中调用的服务的响应接收,那么它将不会进入异常策略。