Search code examples
androidasp.netweb-servicesksoap2

Android ASP web service with KSOAP2


I'm developing Android with KSOAP2.

I get the following error:

java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

My code is:

SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);    
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(Request);
    try {
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

        androidHttpTransport.call(SOAP_ACTION, envelope);

        SoapObject response = (SoapObject) envelope.getResponse();
        String result = response.getProperty(0).toString();
    textView1.setText(result);

    } catch (Exception e) {
    //textView1.setText(e.getMessage());

    }

Solution

  • You're using an SSL (HTTPS) connection, and your server's certificate is probably self-signed (which is why your phone can't validate the trust chain.)

    Your easiest solution is to try without HTTPS and get it running, then get a real, signed cert.

    There are ways to work around self-signed SSL certs on Android, too, but judging from your question I think that the time is better spent not delving into that.