【问题标题】:Log raw SOAP exception response with Mule 3.3.1使用 Mule 3.3.1 记录原始 SOAP 异常响应
【发布时间】:2013-10-24 21:27:51
【问题描述】:

如何使用 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"/>

【问题讨论】:

  • 您是否收到来自您正在进行的出站呼叫的 SOAP 错误?还是你想捕获异常并给出 SOAP 错误?
  • 我想记录来自服务的原始响应。我相信我得到了合适的com.example.ServiceException。
  • 当您从正在调用的服务收到异常时,不会记录任何响应。 paylaod 包含从您的流程发送的发布请求。如果要返回一个 SOAP 错误,那么它应该由您在基于异常的异常策略中准备好。
  • 如果 SOAP 错误作为您从流程中调用的服务的响应接收到,那么它不会进入异常策略。

标签: soap mule


【解决方案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" />

希望这会有所帮助。

【讨论】:

    【解决方案2】:

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

    <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"/>
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-26
      • 2019-06-14
      • 1970-01-01
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      • 2015-05-21
      • 2023-04-02
      相关资源
      最近更新 更多