2013-10-24 52 views
0

原始SOAP異常響應我如何才能登錄用騾子3.3.1原始SOAP異常響應?當我在這樣定義與myStrategy沿着流的末尾添加一個<exception-strategy ref="myStrategy"/>日誌與騾子3.3.1

<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

你從出站接收SOAP錯誤叫你正在?或者你想o捕獲異常並給SOAP錯誤? – user1760178

+0

我想記錄服務的原始響應。我相信我得到了適當的'com.example.ServiceException'。 – ipavlic

+0

當您收到來自您正在呼叫的服務的異常時,則不會記錄響應。 paylaod包含您的流程發送的發佈請求。如果要返回SOAP錯誤,則應該根據異常情況在異常策略中準備好。 – user1760178

回答

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

希望這會有所幫助。獲得原始有效載荷在<catch-exception-strategy>

1

最好的辦法是原來的有效載荷存儲在一個變量在你的流程的第一件事,然後訪問它的異常塊。

<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]並用它作爲必要的。

這種技術是非常有用的,我都做差不多幾乎流,不論它有肥皂入站或其他,原有效載荷將永遠是不可訪問