0

Mule 3.3.1 で生の SOAP 例外応答をログに記録するにはどうすればよいですか? <exception-strategy ref="myStrategy"/>フローの最後にa を追加すると、次の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タイプのようです。で SOAP 呼び出しの詳細を確認できます 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]し、必要に応じて使用します。

この手法は非常に便利で、SOAP インバウンドなどに関係なく、ほぼすべてのフローで実行します。元のペイロードにアクセスできなくなることはありません。

于 2013-10-24T13:18:20.207 に答える