简体   繁体   中英

ksoap2 with https wsdl web service in android

I am trying to access data from wsdl web service with using ksoap2 that is working good with http address but when i change address with added https the not working error occured.

I am using following Code.

public VectorAppContact GetContactList(String passCode,String tokenID,List<HeaderProperty> headers){


    SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    soapEnvelope.implicitTypes = true;
    soapEnvelope.dotNet = true;
    SoapObject soapReq = new SoapObject("http://tempuri.org/","GetContactList");
    soapReq.addProperty("passCode",passCode);
    soapReq.addProperty("tokenID",tokenID);         

    soapEnvelope.setOutputSoapObject(soapReq);
    //HttpsTransportSE httpTransport=new HttpsTransportSE(url, 443, "", timeOut);

    HttpTransportSE httpTransport = new HttpTransportSE(url,timeOut);
    try{
        if (headers!=null){
            httpTransport.call("http://tempuri.org/ISyncService/GetContactList", soapEnvelope,headers);
        }else{
            httpTransport.call("http://tempuri.org/ISyncService/GetContactList", soapEnvelope);
            Object result = (Object)soapEnvelope.getResponse();
            Log.i("respose get", ""+result.toString());
        }
        Object retObj = soapEnvelope.bodyIn;
        if (retObj instanceof SoapFault){
            SoapFault fault = (SoapFault)retObj;
            Exception ex = new Exception(fault.faultstring);
            if (eventHandler != null)
                eventHandler.Wsdl2CodeFinishedWithException(ex);
        }else{
            SoapObject result=(SoapObject)retObj;
            if (result.getPropertyCount() > 0){
                Object obj = result.getProperty(0);
                SoapObject j = (SoapObject)obj;
                VectorAppContact resultVariable = new VectorAppContact(j);
                return resultVariable;
            }
        }
    }catch (Exception e) {
        if (eventHandler != null)
            eventHandler.Wsdl2CodeFinishedWithException(e);
        e.printStackTrace();
    }
    return null;
}

when i use url http://somthing.com/ like then work but when I used url https://somthing.com like then it gives following Exception.

06-06 10:14:32.339: W/System.err(2090): org.ksoap2.transport.HttpResponseException: HTTP request failed, HTTP status: 415
06-06 10:14:32.339: W/System.err(2090):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:237)
06-06 10:14:32.339: W/System.err(2090):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:118)
06-06 10:14:32.339: W/System.err(2090):     at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:113)
06-06 10:14:32.339: W/System.err(2090):     at com.ht.mysecureclient.SyncService.GetContactList(SyncService.java:118)
06-06 10:14:32.339: W/System.err(2090):     at com.ht.mysecureclient.SyncService.GetContactList(SyncService.java:99)
06-06 10:14:32.339: W/System.err(2090):     at com.ht.corpsync.GetData$1.doInBackground(GetData.java:76)
06-06 10:14:32.339: W/System.err(2090):     at com.ht.corpsync.GetData$1.doInBackground(GetData.java:1)
06-06 10:14:32.339: W/System.err(2090):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
06-06 10:14:32.339: W/System.err(2090):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
06-06 10:14:32.339: W/System.err(2090):     at java.util.concurrent.FutureTask.run(FutureTask.java:138)
06-06 10:14:32.339: W/System.err(2090):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
06-06 10:14:32.339: W/System.err(2090):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
06-06 10:14:32.339: W/System.err(2090):     at java.lang.Thread.run(Thread.java:1019)

I googled too much but did not find the any solution please any one help me thanks in advance.

I found you did not use HttpsTransportSE type which is required for https.

HttpsTransportSE httpTransport = new HttpsTransportSE(url,timeOut);

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