Web services stub generation + android

只愿长相守 提交于 2019-12-21 12:01:07

问题


I want to generate a android(java) based STUB for accessing all the web services. I have tried generating the stub using following tools:

1) Sun Java (TM) Wireless Toolkit 2.5.2_01 for CLDC,

2) ksoap2-generating-stub-0.1-SNAPSHOT-J2me-Android.

But i was unable to generate a proper stub that can be used. Please suggest any library or tool that you have used for the purpose.

thanks!!

Anyone here!!

Update:

Problem with sun java lib: There are some java libs that are not supported by Android. For eg: "javax.microedition.xml.rpc.Operation" etc.

Problem with ksoap2: getting a null pointer exception with following log in command prompt:

command that i run using windows command prompt:

java -cp ksoap2-generating-stub-0.1-SNAPSHOT-jar-with-
dependencies.jar;"%JAVA_HOME%\lib\tools.jar"
ksoap2.generator.Wsdl2Android -w "http://localhost:8080/Ws2Ksoap/
services/HelloWorld?wsdl" -g .\generated

As soon as i am running this code,i am getting following exception:

Exception in thread "main" java.lang.NullPointerException
        at ksoap2.generator.WsCompiler.compile(WsCompiler.java:86)
        at ksoap2.generator.WsCompiler.run(WsCompiler.java:78)
        at ksoap2.generator.Wsdl2J2me.run(Wsdl2J2me.java:116)
        at ksoap2.generator.Wsdl2Android.main(Wsdl2Android.java:41) 

Another Update: The created web services must not use any instance of java.rmi.* package.


回答1:


have you included the ksoap2 jar file to your project ...? I had done and example of webservice using ksoap2 and got it successfully. I had used and online web service of www.w3schools.com, the details of the web service are as follows....

soap_action = "http://tempuri.org/CelsiusToFahrenheit"; method_name = "CelsiusToFahrenheit"; namespace = "http://tempuri.org/"; url = "http://www.w3schools.com/webservices/tempconvert.asmx";

hope this will help you.Good Luck




回答2:


This exception occurred because you run java from JRE, but it searches for a compiler and can't find it. Use java.exe from JDK, like this:

"c:\Program Files\Java\jdk1.6.0_20\bin\java.exe" -cp ksoap2-generating-stub-0.1-SNAPSHOT-jar-with-dependencies.jar;"%JAVA_HOME%\lib\tools.jar" ksoap2.generator.Wsdl2Android -w "http://address/Service.svc?wsdl" -g .\generated



回答3:


There is http://easywsdl.com generator. It uses ksoap2 library and supports complex types (with inheritance), data in attributes, header values and WCF extensions like Guid data type and data contract with IsReference attribute.



来源:https://stackoverflow.com/questions/5937218/web-services-stub-generation-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!