[英]How to get rid of xmlPayload when posting JSON Array through WSO2 API Manager?
我們已經設置了WSO2 API Manager 1.6,並希望在其后面具有RESTful Web服務。 但是,當我們將JSON數組發送到Web服務時,它會被修改。
我們使用axis2.xml_PT是因為我們只希望消息通過。 在Publisher中,我已將端點設置為URL端點,其中“格式”和“優化”選項設置為“按原樣”。 但是當我運行此命令時:
curl -H "Content-Type: application/json" -k -d '[{"price":"9,99"},{"price":"24,99"}]' -v 'http://our.url.here:8280/calle/0.1/'
這就是發送到API管理器后面的Web服務的內容(使用nc -l 1234
捕獲)
POST http://10.87.16.127:1234/ HTTP/1.1
Content-Type: application/json
Accept: */*
activityID: 1277246320952979749505377
Transfer-Encoding: chunked
Host: 1.2.3.4:1234
Connection: Keep-Alive
User-Agent: Synapse-PT-HttpComponents-NIO
33
{"xmlPayload":[{"price":"9,99"},{"price":"24,99"}]}
0
“ xmlPayload”來自哪里? 我不希望消息被閱讀或修改,只是通過傳遞。
如何獲得所需的行為? 當發布JSON對象而不是數組時,它似乎可以正常工作。
更新1:如果我使用Content-Type:文本/純文本,則消息將保持不變。
更新2:我這樣編輯axis2.xml,消息通過OK獲得。 這是正確的方法嗎?
$ diff -Nur axis2.xml.bup axis2.xml
--- axis2.xml.bup 2014-09-18 11:12:04.851000719 +0000
+++ axis2.xml 2014-09-18 11:26:29.421472188 +0000
@@ -167,7 +167,7 @@
<!--JSON Message Formatters-->
<messageFormatter contentType="application/json"
- class="org.apache.axis2.json.JSONMessageFormatter"/>
+ class="org.apache.axis2.format.PlainTextFormatter"/>
<!--messageFormatter contentType="application/json"
class="org.apache.axis2.json.JSONStreamFormatter"/-->
<messageFormatter contentType="application/json/badgerfish"
@@ -229,7 +229,7 @@
<!--JSON Message Builders-->
<messageBuilder contentType="application/json"
- class="org.apache.axis2.json.JSONBuilder"/>
+ class="org.apache.axis2.format.PlainTextBuilder"/>
<!--messageBuilder contentType="application/json"
class="org.apache.axis2.json.JSONStreamBuilder"/-->
<messageBuilder contentType="application/json/badgerfish"
如果您需要傳遞JSON請求有效負載而不觸摸它們,則可以使用以下配置。 然后,它將傳遞請求有效負載,而無需根據任何特定的內容類型進行構建。 通常,對於確實未知的數據類型以及當您只想通過而不根據特定類型進行構建時,我們確實建議使用此構建器格式化程序。
<messageBuilder contentType="text/json"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
請讓我們知道以上解決方案是否有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.