0

I had an update for Android Studio. After it finished, I had a problem with Ksoap2 3.6.2. While I was debugging, it is always in catch block.

To try to solve this I uninstalled Ksoap2 and then installed again. But it still can not connect to Web Services. How can I solve this problem?

SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
        SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        String resTxt = null;
        try {    
            androidHttpTransport.call(SOAP_ACTION + webMethName, envelope);// 1.Step and then goes to catch block
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
            resTxt = response.toString();
        } catch (Exception e) {//problem is here
            e.printStackTrace();
            result.Success = 0;
            result.Message = "Error!!!" + e.getMessage();
            return result;
        }
theduck
  • 2,589
  • 13
  • 17
  • 23

1 Answers1

0

This problem happens because on Android 9 cleartext traffic (http) is restricted by default. What you need to do is add to your manifest:

<application
     android:usesCleartextTraffic="true"

You should avoid using http in production, this is only for development stage.

Daniel
  • 2,320
  • 1
  • 14
  • 27