1

I have already included the Internet Permissions in the andoird manifest page, still the error seems to persist. I am also recieveing an unknown host excption in the similar code. Kindly guide me through! Ty! :)

package name.id;

import android.app.Activity;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import org.ksoap2.*;
import org.ksoap2.serialization.*;
import org.ksoap2.transport.*;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class FirstPage extends Activity implements android.view.View.OnClickListener
{
    /** Called when the activity is first created. */

  TextView tv;
  Button bu;
  EditText et;

  private static final String SOAP_ACTION="http://lthed.com/GetFullNamefromUserID";
    private static final String METHOD_NAME="GetFullNamefromUserID";
    private static final String NAMESPACE="http://lthed.com";
    private static final String URL="http://vpwdvws09/services/DirectoryService.asmx";

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        et=(EditText) findViewById(R.id.editText1);
        tv=(TextView) findViewById(R.id.textView2);
        bu=(Button) findViewById(R.id.button1);
        bu.setOnClickListener((android.view.View.OnClickListener) this);
        tv.setText("");
    }

    public void onClick(View v)
    {           
        // creating the soap request and all its paramaters
        SoapObject request= new SoapObject(NAMESPACE, METHOD_NAME);
        //request.addProperty("ID","89385815");// hardcoding some random value
        //we can also take in a value in a var and pass it there


        //set soap envelope,set to dotnet and set output
        SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        soapEnvelope.dotNet=true;
        soapEnvelope.setOutputSoapObject(request);

        HttpTransportSE obj = new HttpTransportSE(URL);
        //to make call to server
        try
        {
            obj.call(SOAP_ACTION,soapEnvelope);// in out parameter
            SoapPrimitive resultString=(SoapPrimitive)soapEnvelope.getResponse();
            //soapObject or soapString
            tv.setText("Status : " + resultString);
        }
        catch(Exception e)
        {
            tv.setText("Error : " + e.toString());
            //e.printStackTrace();
        }

}
}

3 Answers 3

2

Have you added Internet permission to your manifest:

<uses-permission android:name="android.permission.INTERNET"/>
Sign up to request clarification or add additional context in comments.

1 Comment

Yes! Like i mentoned I have added the internet permissions in the manifest page too. Still it seems to be throwing an error. Thanks for your help anyway!
1

The error was being thrown because of an error in the URL. The URL needed my IP address to function properly rather than the URL i was providing because that the webservice was not able to understand.

Comments

0

Depending on what KSOAP2 version you are using error may vary.

Its recommend that use KSOAP2 v3+ lib.

Simply use following code to override...

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy);

and also use...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.