我希望你能帮助我让 JSON REST WSO2 数据服务工作。我使用 v 3.0.1 和示例数据服务。我怀疑我做错了......我创建了一个绑定到 productsSQL 查询的资源“产品”。XML REST 请求可以完美运行,但 JSON 不行:
curl --request GET http://myserver.com:9763/services/samples/RDBMSSample.HTTPEndpoint/products -H Content-Type:"application/json"
返回
> "Fault":{"faultcode":"","faultstring":"No JSON message received
> through HTTP GET or POST","detail":""}}
从源代码看起来它期望在请求 url 中有一些请求主体(这很奇怪),所以下一个查询是
curl --request GET http://myserver.com:9763/services/samples/RDBMSSample.HTTPEndpoint/products?q=emptyquery -H Content-Type:"application/json"
这个挂起并在几分钟后在服务器上出现以下异常:
> Feb 24, 2013 8:08:13 PM
> org.apache.tomcat.util.net.NioEndpoint$SocketProcessor run SEVERE:
> java.lang.ThreadDeath at java.lang.Thread.stop(Thread.java:776) at
> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.handleStuckThread(CarbonStuckThreadDetectionValve.java:121)
> at
> org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.backgroundProcess(CarbonStuckThreadDetectionValve.java:175)
> at
> org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1387)
> at
> org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1566)
> at
> org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1576)
> at
> org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1555)
> at java.lang.Thread.run(Thread.java:680)
但是,以下查询有效:
curl --data '{"employeesbynumber":{"employeenumber":{"$":"1002"}}}' http://myserver.com:9763/services/samples/RDBMSSample/ --header 内容类型: "application/json" --header SOAPAction:"urn:employeesByNumber"