[英]WSO2 esb: how to proxy REST service with numeric operation name
我們正在嘗試在WSO2 ESB上實現基本的SOAP-to-REST代理服務。 我們的第三方REST服務以下列格式接受請求:
http://<MYURL>/simpleQuery/16783484?oslc.select=value1
問題是操作名稱只有數字格式 - 在我們的例子中是“16783484”。 payloadFactory介體不允許將<16783484>作為XML元素,因為XML規范限制了僅數字元素名稱。
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<payloadFactory>
<format>
<16783484>
<oslc.select>$1</oslc.select>
</16783484>
</format>
<args>
<arg value="myvalue1"/>
</args>
</payloadFactory>
<send>
<endpoint>
<address uri="http://<MYURL>/simpleQuery" format="get"/>
</endpoint>
</send>
<drop/>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
</proxy>
怎么能克服這個?
感謝您的幫助!
WSO2支持團隊建議采用以下解決方案。 謝謝Sandapa!
在這種情況下,您必須將端點格式設置為“休息”。 如果是GET請求,則必須將'HTTP_METHOD'設置為GET。 請參考下面給出的示例。
例:
<proxy xmlns="http://ws.apache.org/ns/synapse" name="CQProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<property name="REST_URL_POSTFIX" value="/getSimpleQuote?symbol=IBM" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService/" format="rest"/>
</endpoint>
</send>
<drop/>
</inSequence>
<outSequence>
<log level="full"/>
<send/>
</outSequence>
</target>
<description></description>
</proxy>
雖然這個評論不會建議你一個解決方案,但我可以說這是一個壞主意:-)你可以嘗試使用XSLT而不是PayloadFactory進行轉換,但同樣可能會扼殺XML解析器。 問題是WSO2產品使用的許多開源項目/庫,你可能碰到其他地方將遵守規范。 從長遠來看,當您與其他外部工具/系統集成時,遵守規范將減少您的麻煩。 是否可以更改您的休息服務,以便服務名稱至少在前面有下划線?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.