java - Android Socket is closed error -
i developing android application trying connect server username validation.. getting error "java.net.socketexception : socket closed" ... giving code below if can pls help....
mainactivity
webservicecallbutton = (button)findviewbyid(r.id.login_button); etusername = (edittext)findviewbyid(r.id.edittextlogin); etpassword = (edittext)findviewbyid(r.id.edittextpassword); webserviceresponse = (textview) findviewbyid(r.id.textview1); webservicecallbutton.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub webserviceresponse.settext("requesting server ....."); //create webservice class object webservicecall com = new webservicecall(); // initialize variables string id = "99999999999"; string password = "01233333"; //call webservice class method , pass values , response string aresponse = com.getmlogin("mlo",id,password); //alert message show webservice response toast.maketext(getapplicationcontext(), id+" id= "+aresponse+" hi", toast.length_long).show(); log.i("androidexampleoutput", "----"+aresponse); webserviceresponse.settext("response : "+aresponse); } }); } webservicecall
string namespace = "https://xxxx.xxxx.com/"; private string url = "https://xxxx.xxxx.xxxxxx.com/appservice/d_service.asmx"; string soap_action = "https://xxxxx.com/mlo"; soapobject request = null, objmessages = null; soapserializationenvelope envelope; androidhttptransport androidhttptransport; webservicecall() { } /** * set envelope */ protected void setenvelope() { try { // creating soap envelope envelope = new soapserializationenvelope(soapenvelope.ver11); //you can comment line if web service not .net one. envelope.dotnet = true; envelope.setoutputsoapobject(request); androidhttptransport = new androidhttptransport(url); androidhttptransport.debug = true; } catch (exception e) { system.out.println("soap exception---->>>" + e.tostring()); } } // methodname variable define webservice function call public string getmlogin(string mlo, string customerid, string customername) { try { //soap_action = namespace + methodname; //soap_action = namespace + methodname; //adding values request object request = new soapobject(namespace, mlo); //adding string value request object request.addproperty("customerid", "" + customerid); request.addproperty("customername", "" + customername); setenvelope(); try { //soap calling webservice androidhttptransport.call(soap_action, envelope); //got webservice response string result = envelope.getresponse().tostring(); return result; } catch (exception e) { // todo: handle exception return e.tostring(); } } catch (exception e) { // todo: handle exception return e.tostring(); } }
this exception means have closed socket , tried use again.
if close input or output stream automatically close other stream, , socket.
just close down when finished completley
Comments
Post a Comment