Android IO Exception - No such file or directory

629 views Asked by At

I am connecting my Android application with webservice .asmx... I am getting an error like IOException no such file or directory. I am giving my code below.. I am getting toast message"Pls try later" so general exception is happening.

webserviceCallButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            new login().execute();
        }
    });
}

class login extends AsyncTask<Void, Void, Void> {

    private final ProgressDialog dialog = new ProgressDialog(Sample1_Page.this);

    @Override
    protected void onPreExecute() {
        this.dialog.setMessage("Loading data");
        this.dialog.show();
    }

    @Override
    protected Void doInBackground(Void... unused) {
        final String NAMESPACE = "https://xxx.xxxx.com/";
        final String URL = "https://xxx.xxxx.xxx.com/appservice/d_service.asmx";
        final String SOAP_ACTION = "https://xxxx.xxx.com/mLo";
        final String METHOD_NAME = "mLo";

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        request.addProperty("userid", userid);
        request.addProperty("password", password);


        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        androidHttpTransport.debug = true;

        try {
            androidHttpTransport.call(SOAP_ACTION, envelope);
            SoapPrimitive response = (SoapPrimitive) envelope.getResponse();

            String responseJSON=response.toString();
            JSONArray jarray =new JSONArray(responseJSON);

            Name=jarray.getJSONObject(0).getString(TAG_NAME);
            Id=jarray.getJSONObject(0).getString(TAG_ID);

            System.out.println(request);
            System.out.println(responseJSON);
        }
        catch(SocketTimeoutException e){
            timeoutexcep=true;
            e.printStackTrace();
        }
        catch(UnknownHostException e){
            httpexcep=true;
            e.printStackTrace();
        }
        catch (Exception e) {
            genexcep=true;
            e.printStackTrace();
        }

        return null;
    }

    @Override
    protected void onPostExecute(Void result) {
        if (this.dialog.isShowing()) {
            this.dialog.dismiss();
        }
        if(timeoutexcep){
            Toast.makeText(Sample1_Page.this, "Unable to connect to server, Please try again later",Toast.LENGTH_LONG).show();
        }
        else if(httpexcep){
            Toast.makeText(Sample1_Page.this, "Please check your Internet connection",Toast.LENGTH_LONG).show();
        }
        else if(genexcep){
            Toast.makeText(Sample1_Page.this, "Please try later",Toast.LENGTH_LONG).show();        
        }
        else{
            tableview();
        }

        timeoutexcep=false;
        httpexcep=false;
        genexcep=false;
    }    

    public void tableview(){
        try{
            TextView webserviceResponse = (TextView) findViewById(R.id.textView1);
            webserviceResponse.setText(Name);
        }
        catch(Exception e){
        }
    }
}

Logcat

Java.io.IOException: Errror running exec(). Command: [su] Working Directory: null Environment : null
at java.lang.ProcessManager. exec(ProcessManager.java.211)
at java.lang.Runtime.exec(Runtime.java : 168)
at java lang.Runtime. exec(Runtime.java : 241)
at java.lang.Runtime.exec (Runtime.java:248)
at android.os.AsyncTask&2.call(AsyncTask.java:287)
at java.util.concurrent.futureTask$Sync.innerRun(FutureTask.java:305
caused by: java.io.IOExceptio: No such file or directory    
1

There are 1 answers

6
Pankaj Sakariya On

Can you show me your manifest permissions?

You must have this permission. If not then add this.

android.permission.WRITE_EXTERNAL_STORAGE

Also check your web service's protocol, is it https or http? try to use ip address of your server. it may help you.