来自Axis2 Web Service的JSON响应

时间:2013-06-26 12:25:41

标签: wso2 axis2

我正在使用Axis2开发Web服务,创建.aar file并在WSO2 Application Server.中部署它成功部署Axis2服务并返回如下响应。

<ns:serviceResponse xmlns:ns="http://service.axis.example.com">
    <ns:return>{"status":"SUCCESS"}</ns:return>
</ns:serviceResponse>  

但我期待JSON响应。由于Axis2支持JSON响应,我尝试通过修改axis2.xml(启用messageBuilder and messageFormatter)来遵循以下教程,但是没有成功。
http://axis.apache.org/axis2/java/core/docs/json_support.html
http://www.javacodegeeks.com/2012/02/json-web-service-with-java-and-axis2.html
此外,
我尝试从UI(wso2dynamic-response-20080916.170559-241.mar)部署Modules Tab -> Add,并将上传的文件部署到以下位置(CARBON_HOME / repository / deployment / server / axis2modules)。
我根据I can't to return json objects using Axis2中的建议尝试复制wso2dynamic-response-1.5.jar但仍然获得XML响应而不是JSON。

请让我知道我做错了什么,并指导正确的方向 在此先感谢。

2 个答案:

答案 0 :(得分:1)

将 JSONMessageFormatter.getJSONWriter 帮助

答案 1 :(得分:0)

在axis2.xml中启用JSON消息格式化器应该可以工作..无论如何,你的响应的内容类型是什么?..应该是application / json

相关问题