本文介绍了消费Axis2 Web服务使用JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个Android应用程序使用Axis2 Web服务。如果这有什么差别Axis2的服务使用JDK1.5。

I need to consume an Axis2 web service with an Android application. The Axis2 service is using JDK1.5 if it makes any difference.

我做的Axis2给JSON输出。事实证明,这是比较简单的,只需通过修改axis2.xml并添加正确的MessageFormatter和MessageBuilder。

I made Axis2 give JSON outputs. This turned out to be relatively simple, simply by modifying axis2.xml and adding the correct MessageFormatter and MessageBuilder.

调用与网址的服务,现在导致JSON输出,并且我可以通过修改请求URL传递参数:

Calling the service with the URL now results in a JSON output, and I can pass parameters in by modifying the request url:

http://myServer.com/axis2/Services/myService/myOperation?
    param1=asdf&response=application/json/badgerfish

不过,我似乎无法使由实际发送JSON请求接受电话。这些要求似乎也形成JSON,但是服务拒绝他们。纵观,它看起来会很容易如果我用的是Axis2的存根(步骤2和3)。不过,我不是(我似乎无法得到客户的Axis2 code在Android上工作,但是这是一个不同的故事)。

However, I can't seem to make calls that are accepted by actually sending JSON requests. The requests seem to be well-formed JSON, but the service rejects them. Looking at the Axis2 documentation, it looks like it would be easy if I was using the Axis2 stub (steps 2 and 3). However, I'm not (I can't seem to get Axis2 client code to work on Android, but that's a different story).

我如何发送JSON请求到一个JSON启用的Axis2服务?

How can I send JSON requests to a JSON enabled Axis2 service?

推荐答案

您可以做到这一点的唯一方法是通过使用RawXMLInOutMessageReceiver,和你自己解析XML有效载荷。 Axis2的JSON支持是非常弱的,你不能随数据绑定使用。

The only way you can do this is by using the RawXMLInOutMessageReceiver, and parse the XML payload yourself. Axis2 JSON support is very weak, and you can't use it along with data binding.

请参阅从笔者自己的评论。

See the comment from the author himself.http://isurues.wordpress.com/2009/10/06/how-to-use-axis2-json/

这篇关于消费Axis2 Web服务使用JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 10:14