Question

has any one been able to connect to a soap server using ksoap2 android via https?

I keep getting the error that "Hostname <###>was not verified"

I'm doing

AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport (URL);
androidHttpTransport.call(SOAP_ACTION, envelope);

apparently looking back at other ksoap which isn't for android your ment to us a different call to connect via https, but i can't find a way to do it in the android version.

Anyone found a way about or know the call im ment to use?

thanks for you help

Was it helpful?

Solution

android ksoap2 2.5.2 is out which supports https

http://code.google.com/p/ksoap2-android/

the problem is i dont quite sure how to use it

HttpsTransportSE aht = new HttpsTransportSE(host, port, file, timeout)

what shoud i enter for "file" parameter? anybody have any idea?

btw AndroidHttpTransport is deprecated in the latest version of ksoap2

OTHER TIPS

Well, you'll need to do two things on Android devices:

  1. For SSL you need to trust the server certificate. You can either install a fake trust manager like here (http://groups.google.com/group/android-developers/browse_thread/thread/1ac2b851e07269ba/c7275f3b28ad8bbc?lnk=gst&q=certificate and then call allowAllSSL() before you do any SSL communication/call to ksoap2) or put some more effort into this, make it safer and follow the instructions of saxos, I guess.
  2. Then you need to use ksoap2-android or more specifically the class (KeepAlive)HttpsTransportSE like this new KeepAliveHttpsTransportSE(host, port, file, timeout);. The parameters go into a URL object, so e.g. to access a Jira installation it's something like new KeepAliveHttpsTransportSE("host.whatever", 443, "/rpc/soap/jirasoapservice-v2", 1000)

Btw.: I wrote on "Android devices", because I find it useful to test the stuff first in a J2SE environment and here the (KeepAlive)HttpsTransportSE stuff is missing in the lib (I used ksoap2-j2se-full-2.1.2.jar). Just get the sources for the three classes HttpsTransportSE, KeepAliveHttpsTransportSE, and HttpsServiceConnectionSE from ksoap2-android and put them into your J2SE project and use them. It works and is a productivity improvement to get the first steps with an unknown web service (if you know the web service and how to tweak ksoap2, it's of no use, but it was handy for me as I was new to ksoap2 and its android spin-off).

You can set the filename as empty string (""). Looking at the source code of ksoap it passes the parameter to java.net.URL and from the Sun Javadoc it refers to file - "the file on the host". I have given up trying to use ksoap2 for SOAP https calls. Issue is with the way Android processes SSL connections. The only solution seems to be creating a local keystore to store the SSL certificate and writing a wrapper around the Apache Httpclient to use the certificate. So I might as well implement these calls using REST. Guess that's what Google wants us to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top