2013-02-21 53 views
0

我正在爲我的公司開發WSO2 ESB POC,它涉及通過ESB上的SOAP端點公開內部RESTful服務。我已經閱讀了與SOAP-REST中介有關的所有線程和博客帖子,但仍然找不到答案。 我的RESTful服務返回「application/rdf + xml」消息格式。這裏是我的序列:WSO2 ESB:將來自RDF REST服務的響應記錄並轉換回SOAP

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 
    <target> 
     <inSequence> 
     <send> 
      <endpoint> 
       <address uri="http://<MYURL>/cqweb/oslc/repo/eraprototype/db/CQT_T/simpleQuery/16783484?oslc.select=dcterms:title,cq:CM_Label,dcterms:type,cq:Assigned_To,oslc_cm:status,cq:AutoDeployment,cq:SentToEADS_By&oslc.where=oslc:shortTitle=CQT_T00000131" format="get"/> 
       <property xmlns:ns="http://org.apache.synapse/xsd" name="Authorization" expression="fn:concat('Basic ', base64Encode('user:password'))" scope="transport"/> 
       <property name="OSLC-Core-Version" value="2.0" scope="transport"/> 
       <property name="Accept" value="application/rdf+xml" scope="transport"/> 
      </endpoint> 
     </send> 
     </inSequence> 
     <outSequence> 
     <log level="full"/> 
     <send/> 
     </outSequence> 
    </target> 
    <publishWSDL key="gov:/services/cqproxy/CQProxy.wsdl"> 
     <resource location="CQProxy.xsd" key="gov:/services/cqproxy/CQProxy.xsd"/> 
     <resource location="eads_ws.xsd" key="gov:/services/eads_ws/eads_ws.xsd"/> 
    </publishWSDL> 
    <description></description> 
</proxy> 

我能夠將請求成功發送到RESTful服務。但是,我的OUT序列無法處理「application/rdf + xml」響應。日誌顯示以下錯誤:

INFO {org.apache.axis2.builder.BuilderUtil} - OMException in getSOAPBuilder {org.apache.axis2.builder.BuilderUtil} 
org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found RDF 


兩個問題:
1.如何日誌從REST服務接收Axis2的SOAP應用改造前的實際響應?我的日誌中介只生成空的SOAP信封。

INFO {org.apache.synapse.mediators.builtin.LogMediator} - To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:4c06fcb9-4e45-4fb3-bc5a-4350e3d86533, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> {org.apache.synapse.mediators.builtin.LogMediator} 


2.如何將RDF + XML轉換回SOAP格式?我應該在OUT序列中使用XSLT中介嗎?

感謝您的幫助!

回答

2

我寫了一個簡單的Nodejs服務,它發送一個RDF格式的消息。這是使用Advanced Rest Client Chrome擴展程序調用它時的樣子。

invoking rdf endpoint

然後我在ESB 4.5.1創建代理服務。這裏是我的代理服務配置,

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> 
    <target> 
     <inSequence> 
     <log level="full"/> 
     <send> 
      <endpoint> 
       <address uri="http://localhost:8080/" format="pox"/> 
      </endpoint> 
     </send> 
     <log level="full"/> 
     <drop/> 
     </inSequence> 
     <outSequence> 
     <log level="full"/> 
     <send/> 
     </outSequence> 
    </target> 
    <description></description> 
</proxy> 

然後我用tryIt工具發送XML消息到這個代理服務。我正在使用日誌中介來記錄傳入的XML消息。

在輸出序列中,我再次使用日誌中介,我可以看到RDF在那裏登錄。

什麼是您正在嘗試使用的ESB版本?

+0

我正在使用WSO2 ESB 4.6。你的代理配置有點不同金塔:) :) 1.我的REST服務需要「get」消息格式,它拒絕「痘」。 2.我的代理髮布WSDL。你可以修改你的配置來包含這兩件事情,然後重試嗎? – 2013-02-27 15:25:33

+0

進行了2次更改。代理仍然工作。然後我嘗試了4.6.0,我得到了同樣的錯誤。對我來說,這看起來像是新的Passthrough傳輸4.6.0中的一個bug。我會多做點事。可能是它需要一個額外的配置。快速解決方案是在'/repository/conf/axis2/axis2.xml'文件中註釋傳遞傳輸(transportSender位和transportReceiver位)並切換到NIO傳輸。我檢查了一下,並發現它有效 – 2013-02-27 17:38:07

+0

它現在有效!謝謝你,金塔納!我應該向WSO2 ESB 4.6提交缺陷嗎? JIRA? – 2013-02-27 18:40:44

相關問題