生成Java从WSDL为在Android上使用与ksoap2-安卓SOAP客户端? [英] Generating Java from WSDL for use on Android with ksoap2-android SOAP client?

查看:286
本文介绍了生成Java从WSDL为在Android上使用与ksoap2-安卓SOAP客户端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不从一个Android应用程序访问现有的SOAP Web服务。我已经提供了一些描述Web服务的WSDL文件。阅读一些其他的答案在这里SO ,似乎<一HREF =HTTP://$c$c.google.com/p/ksoap2-android/> ksoap2-的Andr​​oid 是要走的路,对于要使用的SOAP客户端

I have to access a existing SOAP webservice from an Android application. I have been provided some WSDL files describing the webservice. Reading some other answers here on SO, it seems ksoap2-android is the way to go, with respect to which SOAP client to use.

接下来的问题是,那么如何来从WSDL文件所需的Java类,而这正是我来了短。据我可以看到有以下选项:

The next issue is then how to generate the Java classes needed from the WSDL files, and this is where I am coming up short. As far as I can see there are the following options:

  1. AXIS2 code发电机
  2. WSDL2ksoap
  3. JAX-WS wsimport工具
  1. AXIS2 code generator
  2. WSDL2ksoap
  3. JAX-WS wsimport tool

我最初尝试#1,与Axis2的Eclipse插件的wsdl2 code发电机。该向导没有成功地产生大量的Java code,但它也改变了我的Andr​​oid项目某种web服务的项目,我从来没有能够拿到生成编译,让与ksoap2,机器人单独工作的任何东西。有没有人有成功呢?

I initially tried #1, with the AXIS2 eclipse plugin for wsdl2code generator. The wizard did successfully generate a lot of Java code, however it also changed my android project to some kind of webservice project, and I was never able to get anything that was generated to compile, let alone work with ksoap2-android. Has anybody has success with this?

我不能够运行wsdl2ksoap成功,因为它似乎需要一个正在运行的web服务,以及所有我在目前的时间点是WSDL文件。同样,从阅读的网页,它似乎是在其初始阶段的一个项目,而不是真正的黄金时间做好准备。

I am not able to run wsdl2ksoap successfully, as it seems to require a running webservice, and all I have at the current point in time is WSDL files. Likewise from reading the webpage, it seems to be a project in its initial stages, and not really ready for prime time.

JAX-WS的wsimport我还没有机会去尝试呢。但是我不能确定,如果它产生将与ksoap2-机器人?

JAX-WS wsimport I have not had a chance to try yet. However I am unsure if what it generates will work with ksoap2-android?

问:我怎样才能生成WSDL文件的Java文件,在Android上使用与ksoap2-安卓SOAP客户端库

感谢很多提前。

(PS:是的,选择的是SOAP,这是最理想的Andr​​oid版应用,但我不能改变的)

(PS: Yes, the choice is SOAP, it is suboptimal for Android use, but I cannot change that.)

推荐答案

我后,相当多的研发的结论是,没有这样的(成熟)的工具可用,很遗憾。无论AXIS2或JAX-WS将致力于Android和WSDL2ksoap简直是太不成熟了任何实际用途。

My conclusion after quite a bit of researching is that there is not such (mature) tool available, unfortunately. Neither AXIS2 or JAX-WS will work on Android, and WSDL2ksoap is simply too immature for any real use.

然而,有一个叫做专有工具 wsclient ++ 将做的工作非常好。 (读取,更新,下面,当投入实际使用,它不站的距离都没有。)不使用kso​​ap2,Android客户端库,它有它自己的。

However there is a proprietary tool called wsclient++ that will do the job really well. (Read update below, when put to real use, it does not stand the distance at all.) It does not use the ksoap2-android client library, it has it's own.

客户端库是有点粗糙,因为它有一个硬依赖于HTTP传输,从而(单位)测试有点复杂。但它可以很容易地修改,以允许DI,作为源是在分布式jar文件可用。

The client library is a bit crude as it has a hard dependency on the http transport, making (unit) testing a bit complicated. But it can be modified quite easily to allow DI, as the source is available in the distributed jar file.

的WSDL到Java的发电机但是工作只是完美的,会为我们节省大量的时间。

The wsdl to java generator however works just perfect, and will save us tons of time.

更新 正与 wsclient ++ 一段时间后,很明显,所生成的类是真正的原油,并在所有不处理错误的案件。 (每一个方法声明抛出异常)。

Update After working with wsclient++ for a while, it is clear that the generated classes are really crude, and does not handle error cases at all. (Every method declares throws Exception).

我们不再使用wsclient ++,我不会建议任何人使用它! 我们还没有真正找到任何工作的替代,很遗憾。 :/

We are no longer using wsclient++, and I would not recommend anyone to use it! We have not really found any working alternative, unfortunately. :/

在最后,我们转换我们的WSDL文件,使用Axis2,然后写了一堆自定义脚本的剥离和转换生成的Java文件的东西,将建立在Android上使用kso​​ap2-的Andr​​oid库。体力劳动非常hackish的,并且需要吨运行。不幸。如果你找到一个更好的办法,或者一个出现时,请提供一个新的答案。

In the end we converted our WSDL files using AXIS2, and then wrote a bunch of custom script to strip and transform the generated java files to something that will build on android using ksoap2-android library. Very hackish, and needs tons of manual labor to run. Unfortunately. If you find a better way, or one comes up, please provide a new answer.

这篇关于生成Java从WSDL为在Android上使用与ksoap2-安卓SOAP客户端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆