简体   繁体   中英

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());

    }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM