2013-11-25 71 views
1

如何在代理中調用web服務?代理本身工作正常,並且我以「in」的順序添加了記錄Web服務的調用。我使用有效載荷工廠+發送創建呼叫。如何在WSO2代理中調用webservice

問題是,該代理現在返回此日誌記錄Web服務的結果,而不是 Web服務應返回的結果。在「out」序列中定義了地址終點。

我正在使用WSO2 ESB 4.6.0。

回答

2

這是在代理內部調用Web服務的簡單示例。您需要了後端服務之前創建的代理

<proxy xmlns="http://ws.apache.org/ns/synapse" name="customPro" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 
    <target> 
     <inSequence> 
     <send> 
      <endpoint> 
       <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
      </endpoint> 
     </send> 
     </inSequence> 
     <out-sequence> 
     <send/> 
     </outSequence> 
    </target> 
    <publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/> 
    <description></description> 
</proxy> 

您需要在標籤終點中定義Web服務URL

除了,這種發送中介復位端部點響應outSequence 默認情況下。

你可以得到這些好理解,如果你去通過ESB文檔從以下網址

http://docs.wso2.org/display/ESB460/Samples

如果您需要進一步的幫助,隨意問這裏

+0

你好,謝謝你的回覆。我會盡力解釋我的意思;我已經像前面顯示的代理,但我想添加對日誌Web服務的調用,這是我使用payloadFactory定義的請求。我可以提出請求,但我從記錄Web服務獲取響應,而不是在示例中使用的地址終點。我一直在閱讀樣本,但沒有回答我的問題。 – Jaba

1

有兩種方式可以實現日誌

1.通過線路日誌記錄ESB進入和出站消息。

爲導線日誌啓用調試模式; - ESB console> Configure> Logging - 將「org.apache.synapse.transport.http.wire」級別設置爲「DEBUG」。

在日誌中,則表明>>傳入郵件ESB

    << outgoing messages from ESB 

2.使用日誌在適當的位置

<?xml version="1.0" encoding="UTF-8"?> 
<proxy xmlns="http://ws.apache.org/ns/synapse" 
     name="TestProxy" 
     transports="https,http" 
     statistics="disable" 
     trace="disable" 
     startOnLoad="true"> 
    <target> 
     <inSequence> 
     <log level="full"> 
      <property name="test" value="incomming to ESB-----------------------"/> 
     </log> 
     <send> 
      <endpoint> 
       <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
      </endpoint> 
     </send> 
     <log level="full"> 
      <property name="test" value="outcomming from ESB-----------------------"/> 
     </log> 
     </inSequence> 
     <outSequence> 
     <log level="full"> 
      <property name="test" value="incomming to ESB-----------------------"/> 
     </log> 
     <send/> 
     <log level="full"> 
      <property name="test" value="outcomming from ESB-----------------------"/> 
     </log> 
     </outSequence> 
    </target> 
    <publishWSDL uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/> 
    <description/> 
</proxy> 

如果解決您的問題,請標誌作爲回答。

+0

我已經有這樣的日誌記錄,但我想寫日誌到數據庫而不是日誌文件。我用DBReport中介做到了這一點。 – Jaba