web services - “Connection closed by peer” error occurs in Android 7.0 Nougat while calling SOAP webservice using KSOAP2 -


i getting

javax.net.ssl.sslhandshakeexception: connection closed peer

while calling soap webservice using ksoap2 (ksoap2_android_2.6.4) in android 7.0 nougat. have refereed below questions

“connection closed peer” error occurs in android 7.0 nougat while connecting sha256 ca installed windows 2003 server sp2 through https

android 7.0 : 'javax.net.ssl.sslhandshakeexception: connection closed peer

below code calling webservice usiong ksoap

public class validateuserasynctask extends asynctask<string, integer, void> {     progressdialog dialog = new progressdialog(loginactivity.this);     string tempaction = "";      @override     protected void onpreexecute() {         dialog.setmessage("validating user...");         dialog.setcancelable(true);         dialog.show();         super.onpreexecute();     }      @override     protected void doinbackground(string... strings) {          try {             if (splashscreenactivity.checknetworkconnection(getapplicationcontext()) == true) {                 log.d("", "host reachable");                 callingvalidateuser(strings[0], strings[1], strings[2], strings[3], strings[4]);              } else {                 fault = true;                 strfault = "please check internet connection!";             }          } catch (exception e) {             log.d("connection error", "connection error in call service");             e.printstacktrace();         }          return null;     }      @override     protected void onpostexecute(void result) {         super.onpostexecute(result);         try {              dialog.dismiss();             if (splashscreenactivity.checknetworkconnection(getapplicationcontext()) == true) {                  parsingforvalidateuser(envelope_actions);             }             if (fault == true) {                 if (strfault.contains("user name/password not valid")) {                     editor = setpref.edit();                     editor.putboolean("flagvalidateduser", false);                     editor.commit();                 }                 if(strfault.contains("contact hr or submit mobile number"))                 {                     fault = false;                     strfault = "";                     intent = new intent(getapplication(), nomobileregisteractivity.class);                     startactivity(i);                  }                 else                 {                     toast.maketext(getapplicationcontext(), "" + strfault, toast.length_long).show();                     fault = false;                     strfault = "";                 }              }          } catch (exception e) {             e.printstacktrace();         }      }      public void callingvalidateuser(string username, string password, string namespace, string methodname, string url) {          androidhttptransport = new httptransportse(url, 60000);         soapobject request = new soapobject(namespace, methodname);          try {             password = aesencrp.encrypt(password);         } catch (exception e1) {             e1.printstacktrace();         }          request.addproperty("username", username);         request.addproperty("password", password);          log.d("username", "" + username);         log.d("password", "" + password);         log.d("namespace", "" + namespace);         log.d("methodname", "" + methodname);         log.d("url", "" + url);          element[] header = new element[1];         header[0] = new element().createelement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "security");         header[0].setattribute(null, "mustunderstand", "1");          element usernametoken = new element().createelement("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "usernametoken");         usernametoken.setattribute(null, "id", "usernametoken-1");         header[0].addchild(node.element, usernametoken);          element username = new element().createelement(null, "n0:username");         username.addchild(node.ignorable_whitespace, username);         usernametoken.addchild(node.element, username);          element pass = new element().createelement(null, "n0:password");         pass.setattribute(null, "type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#passwordtext");         pass.addchild(node.text, password);         usernametoken.addchild(node.element, pass);          envelope_actions.headerout = header;         envelope_actions.dotnet = true;         envelope_actions.bodyout = request;          envelope_actions.setoutputsoapobject(request);         try {             androidhttptransport.debug = true;             androidhttptransport.call("process", envelope_actions); // calling         } catch (soapfault e) {             log.d("", "soapfault error in call worklist type");             e.printstacktrace();         } catch (xmlpullparserexception e) {             log.d("", "xmlpullparserexception error in call worklist type");             e.printstacktrace();         } catch (unknownhostexception e) {             log.d("", "unknownhostexception error in call worklist type");             e.printstacktrace();          } catch (malformedurlexception e) {             log.d("", "malformedurlexception error in call worklist type");             e.printstacktrace();          } catch (sockettimeoutexception e) {             fault = true;             strfault = "request time out";             log.d("", "sockettimeoutexception error in call worklist type");             e.printstacktrace();          } catch (ioexception e) {             log.d("", "ioexception error in call worklist type");             e.printstacktrace();         }      }      public void parsingforvalidateuser(soapserializationenvelope envelope) {          soapobject result;         db = dbhelper.getwritabledatabase();         try {             result = (soapobject) envelope.getresponse();         } catch (nullpointerexception e) {             e.printstacktrace();         } catch (classcastexception e) {             result = (soapobject) envelope.bodyin;             string res = result.getpropertyasstring(0).tostring();         } catch (soapfault e) {             e.printstacktrace();         }       }  } 

i've asked person handle server config. check whether tls enable or not? waiting reply. i've created network_security_config.xml below

<?xml version="1.0" encoding="utf-8"?> <network-security-config>        <base-config>            <trust-anchors>                <certificates src="system"/>            </trust-anchors>        </base-config> </network-security-config> 

and declared in menifest.xml

android:networksecurityconfig="@xml/network_security_config" 

i have tried putting certificate in pem formate in raw folder can not figure out issue.

kindly guide me doing mistake ?


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -