4

Have tried the KSOAP2 library from a console application using the Eclipse IDE talking to a .NET web service located at http://www.w3schools.com/webservices/tempconvert.asmx. No problem, easy and straight forward. Embedded the code in a simple method, test().

The problem started when I wanted everything to work from an Android application.

Here is a summary of what I have done (and the problem):

1. I generated a new Android project in Eclipse IDE using the Android 2.3.1 SDK and I created also an Android Virtual Device based on the same SDK. No problem when starting the virtual device. Worked just fine.

2. Then I added the uses-permission tag with android:name="android.permission.INTERNET" in AndroidManifest.xml file.

3. After that I added the KSOAP2 library exactly as I did when making the console application.

4. Now I added the method test(), earlier tested and validated, including the correct import statements. Everything looked good. No warnings.

5. Compiled and started the project and on the first line of code I got a class loader failure of SoapObject, i.e. "could not found" org.ksoap2.serialization.SoapObject. The line of code looked something liked this: SoapObject objSoapTest = new SoapObject("http://tempuri.org/", "FahrenheitToCelsius");

Tried to see if it could detect some other class in the same package hence I added this line of code before the above mentioned code: PropertyInfo objPropertyInfo = new PropertyInfo();

Got the same problem... "could not found" org.ksoap2.serialization.PropertyInfo.

What can be the problem here? Have tried to change the "Order and Export" in Java Build Path but with no result. Do I need to put this KSOAP2 library where I have the Android SDK files? I am an hardcore C++ programmer so I dont have so much experience with Eclipse IDE etc so I really need some advise on this one.

In addition to the above mentioned, I also created a Java Swing app, no problem at all to connect to the .net web service. Does AVD have any restrictions regarding access to certain libraries? Do I need to add any other permissions?

Btw 1. I have tested other Android apps, connecting to Internet, streaming picture resources in a ListView and it worked just fine.

Btw 2. I am using Windows 7.

All my best!

Night Coder
  • 53
  • 1
  • 5
  • is step **3** something like: right click on project folder -> build path -> add external jar? that's how I did it. – bigstones Jan 29 '11 at 14:48
  • Yes that is exactly what I did... – Night Coder Jan 29 '11 at 14:53
  • Stefan, Did you get this resolved? I have same problem. Application crashes on first call to kSOAP with... SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); Thanks –  Jun 29 '11 at 22:17
  • 1
    Hi Matt, yes I did manage to solve the problem. What I did, which is actually still very strange that it really worked; is that I changed the path to my external Java jars as follows (and especially to KSOAP2): C:\JavaJARS\KSOAP2. Aftewards, I just copied the file to that location AND I also changed the name of the file to ksoap2.jar. After that, I created a simple "hello world" app, added the jar by creating a new variable in Java build path and voilà - it worked. – Night Coder Jun 30 '11 at 06:53
  • Thanks, Stefan, your way works perfectly for me! I just copied zip file to folder (without white spaces), renamed it to jar and now all works. – Igor V Savchenko Jul 28 '11 at 16:02
  • @Stefan, if you solved your problem, you should add your own answer and accept it. BTW, I solved it in another way – Jose_GD Sep 26 '12 at 18:44

3 Answers3

1

try this way...

1. Right click on your project and go to Properties.
2. go to java build path..//which is on the 5th position on left side
3. go to Order and Export tab.
4. check(Tick Mark) on your selected jar file. and click ok.
5. Now, clean your project and Run. 
Mehul Ranpara
  • 4,245
  • 2
  • 26
  • 39
0

I solved this problem adding the KSOAP2 .JAR as external and making sure the .JAR was checked in the Order and Export tab

Jose_GD
  • 2,279
  • 1
  • 21
  • 34
0

Check that you included the jar: http://developer.android.com/guide/appendix/faq/commontasks.html#addexternallibrary

Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Thank you for your quick reply! Yes, I added a new variable KSOAP2 and added the path to the variable. Have also added the library direct without any name, no change. The same result. Worked perfect with the Console app. I got an exception, InvocationTargetException. In debug mode I also got some information telling me that android.jar has no source attachment. Strange, havent changed the location of the file or the folder structure in any way. – Night Coder Jan 29 '11 at 13:32