[英]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.