troubleshooting Question

Call WebService from Android

Avatar of Neha Ninave
Neha Ninave asked on
.NET ProgrammingGoogleAndroid
1 Comment1 Solution97 ViewsLast Modified:
I am just a beginner in Android. I have to call a web service which I have develop in .NET from Android Studio.  I found lots of code from google but still unable to figure out an issue
Here is my code I don't know if it's correct
public class MainActivity extends AppCompatActivity {

    EditText LoginText;

    String SOAP_ACTION = "";
    String METHOD_NAME = "ReadLogin";
    String namespace = "";
    String url = "https://mywebsite/login.asmx";

public void checkLogin(View view) {
        String login = LoginText.getText().toString();
        RequestParams params = new RequestParams();
        if (isNotNull(login)) {
            //params.put("username", login);
        else {
            Toast.makeText(getApplicationContext(), "Please enter valid email", Toast.LENGTH_LONG).show();

public void call()
        try {

            SoapObject request = new SoapObject(namespace, METHOD_NAME);

            request.addProperty("username", "abc");

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

            HttpTransportSE androidHttpTransport = new HttpTransportSE(url);
            androidHttpTransport.debug = true;

  , envelope);

            SoapObject resultsRequestSOAP = (SoapObject) envelope.bodyIn;

            //final Vector<SoapObject> response = (Vector<SoapObject>)envelope.getResponse();
            //final String str = response.toString();

            //Object result = (Object)envelope.getResponse();
            //String myResult = result.toString();

            Toast.makeText(getApplicationContext(), resultsRequestSOAP.toString(), Toast.LENGTH_LONG).show();

        } catch (Exception e) {
            String mError =e.toString();
            Toast.makeText(getApplicationContext(), mError, Toast.LENGTH_LONG).show();

In catch exception I am getting an error like

In AndroidManifest.xml I already added
<uses-permission android:name="android.permission.INTERNET" />
Neha NinaveMrs

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros