• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Consume Https metro web service from android

 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone,

I have a web service created in java and i am trying to consume it in android. The web service is a secured one and i have the required certificates with me.

I tried consuming a non secure web service and it was successful. But I don't know how to go with the secured one.

For consuming non secure web service I was using ksoap2 jar. any other sugeestions for alternatives are welcome.

Folllowing is the wsdl file. I am not that good in reading the wsdl file. Please let me know how to call the hello() method defined in the web service class.

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the actual problem when the code runs? Is there an exception?
 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to consume the web service in a standard java class using the classes generated by wsimport command.
But when I do the same thing in android and try to run the project, i get a message "failed to load. the project contains error".
I am using eclipse IDE. When I add the generated classes it asks me to add webservices-api-2.2-b03.jar.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like an IDE problem. I have heard anecdotally that in general KSOAP2 works OK on Android.
 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please let me know how to call https web service using ksoap2?

can you please share some sample code for the same?


I am using this code which I gto from one of the website




But here the code doesn't compile. It says method HttpsServiceConnectionSE.setSSLSocketFactory is not defined.

Can you let me know a way how to see the request message when I am consuming the web service using the classes generated by wsimport cammand in normal java application.
So that I can atleast get the correct request message format as i am successful in consuming the web service and calling its methods
by using the wsimport cammand generated classes.


 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf asked if you have heard of anyone who has successfully used ksoap2 on Android. This is an important question. Android does not contain all the Java APIs, and so it is possible the library is not compatible with Android. You should ask the developer of the library. Reading more detail in the error would help you as well. You say the IDE reports "failed to load. the project contains error". There is an error in the project, you need to find it and solve it, and that means reading error messages and logs.

As for the compile problem: Does the API for the HttpsServiceConnectionSE class have a method called setSSLSocketFactory()? Does the type returned from getSSLSocketFactory() match the parameter type for that method? Did you misspell something?
 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If not Ksoap2 then is there any other way to consume https web service in android? I was not able to find any other way.

I got to know about Ksoap but for that also I could manage to get very little information. For ksoap you need to download a jar file.
I followed the steps mentioned in the site and am sure there is no misspelling.
One possible thing can be that the jar file version I am using might be different. but i have tried different versions but the result was same.
The version was not put on the site. I got this information about ksoap and the code from one of the thread posted on stackoverflow.com

I need to use this web service only and am struggling hard to try to figure out a way to do the same.
So if there is any other alternative to consume the web service then please suggest me.
I jus want to consume the service successfully. There is no hard n fast rule to use ksoap.

And also I don't know much about ksoap and whether anyone successfully using it or not or even if this is the only way to consume this kind of web service.

And about the error in project, there is no error in the project. When I add the webservicesapi jar in the libs folder the project fails.
I have removed that jar from the lib folder and my project is working fine. Now only I need to consume the service successfully
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Luke wrote:Ulf asked if you have heard of anyone who has successfully used ksoap2 on Android.

I was actually phrasing it badly. I assumed that the ksoap2-android port was being used; ksoap2 itself does not run on Android (hence the port).
 
Raj roy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any solution for my problem? I dont think any issue with port. I am able to work with a non secure web service. I dont know how to go with https web service
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Several questions: What are line 20 and 21 supposed to accomplish? If they don't compile, why are they there? What happens if you use the same code that works for HTTP for HTTPS?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic