Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:50:39+00:00 2026-05-26T08:50:39+00:00

From the past few days, I have been working on an Android code to

  • 0

From the past few days, I have been working on an Android code to call a local web service. I am using ksoap libraries for Android to call my SOAP web service created in .NET. However, I feel there is something wrong in my code as the response I get when I call the web service from my app hits a catch block . I tried debugging my Android code but I am still not able to solve my problem.
Please can someone tell me what’s wrong or any other simpler way to do this ?

Here is my Android code I have implemented till now :

      package com.demo;
      import java.net.SocketException;
      import org.ksoap2.SoapEnvelope;
      import org.ksoap2.serialization.SoapObject;
      import org.ksoap2.serialization.SoapPrimitive;
      import org.ksoap2.serialization.SoapSerializationEnvelope;
      import org.ksoap2.transport.AndroidHttpTransport;
      import android.app.Activity;
      import android.app.ProgressDialog;
      import android.os.AsyncTask;
      import android.os.Bundle;
      import android.util.Log;
      import android.view.View;
      import android.view.View.OnClickListener;
      import android.widget.Button;
      import android.widget.EditText;

    public class Login extends Activity {
private static final String SOAP_ACTION = "http://tempuri.org/GetLoginDetails";
    private static final String METHOD_NAME = "GetLoginDetails";
    private static final String NAMESPACE = "http://tempuri.org/";
    private static final String URL = "http://10.0.2.2/testlogin/Service1.asmx";

@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Button signin = (Button) findViewById(R.id.regsubmitbtn);

        signin.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {


                        EditText etxt_user = (EditText) findViewById(R.id.usereditlog);
                        user_id = etxt_user.getText().toString();
                        EditText etxt_password = (EditText) findViewById(R.id.pwdeditlog);
                        password = etxt_password.getText().toString();

                        new LoginTask().execute();
                }
        });
}

 String user_id;
String password;
String auth=null;
private class LoginTask extends AsyncTask<Void, Void, Void> {

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

    protected void onPreExecute() {
            this.dialog.setMessage("Logging in...");
            this.dialog.show();
    }

    protected Void doInBackground(final Void... unused) {

             auth = doLogin("lalit", "lalit");
            return null; // don't interact with the ui!
    }

    protected void onPostExecute(Void result) {
        if (this.dialog.isShowing()) {
            this.dialog.dismiss();
        }

         }


       private String doLogin(String user_id, String password) {

    SoapPrimitive resultstring = null;
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("user", user_id);
    request.addProperty("password", password);
    SoapSerializationEnvelope soapenvelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);
    soapenvelope.dotNet = true;                                                      
    soapenvelope.setOutputSoapObject(request);

    AndroidHttpTransport httptransport = new AndroidHttpTransport(URL);
    httptransport.debug = true;

    try {
            httptransport.call(SOAP_ACTION, soapenvelope);
            resultstring = (SoapPrimitive) soapenvelope.getResponse();
            //Log.d("Authenticaion", resultstring+"");
            System.out.println(resultstring);


    }
    catch (SocketException ex) {
        Log.e("Error : " , "Error on soapPrimitiveData() " + ex.getMessage());
        ex.printStackTrace();
    } catch (Exception e) {
        Log.e("Error : " , "Error on soapPrimitiveData() " + e.getMessage());
       e.printStackTrace();
    }
    return resultstring+"";

    }
     }
    }

my web service code :

        using System;
        using System.Collections;
        using System.ComponentModel;
        using System.Data;
        using System.Linq;
        using System.Web;
        using System.Web.Services;
        using System.Web.Services.Protocols;
        using System.Xml.Linq;
        using System.Data.SqlClient;

     namespace LoginDetails
     {
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
// [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
   {


    [WebMethod]
  public String GetLoginDetails(string UserName, string Password)
    {

   try
      { 
     using (SqlConnection myConnection = new SqlConnection(@"Data Source= .\SQLEXPRESS;Initial Catalog=student;User ID=sa;Password=demo"))
    {
        myConnection.Open();

        using (SqlCommand myCommand = new SqlCommand())
        {
            myCommand.Connection = myConnection;
            myCommand.CommandText = "SELECT COUNT(*) FROM Login WHERE UserName = @UserName AND Password = @Password";
            myCommand.Parameters.Add("@UserName", SqlDbType.VarChar).Value = UserName;
            myCommand.Parameters.Add("@Password", SqlDbType.VarChar).Value = Password;
            return (int)myCommand.ExecuteScalar() == 1 ? "success" : "bad username or password";
        }
    }
}
catch (Exception ex)
    {
    Console.WriteLine(ex.Message);
    return "an error occurred.";
     } 

  }

     }


  }

my logcat :

       10-22 21:49:17.635: DEBUG/dalvikvm(117): GC_EXTERNAL_ALLOC freed 901 objects /         

       10-22 21:49:18.015: WARN/KeyCharacterMap(117): No keyboard for id 0
       10-22 21:49:18.015: WARN/KeyCharacterMap(117): Using default keymap:  /system/usr/keychars/qwerty.kcm.bin
       10-22 21:49:22.275: INFO/ARMAssembler(58): generated s   scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x23df98:0x23e054] in 675711 ns
       10-22 21:49:42.025: INFO/System.out(274): an error occurred.
       10-22 21:49:42.045: WARN/InputManagerService(58): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@44eda178

my output during web service call

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:50:40+00:00Added an answer on May 26, 2026 at 8:50 am

    Working with kSOAP2 can be challenging… i know. But it is a good library and I have been able to get it to work. I have written a little on working with kSOAP2 on Android. I discuss passing simple and complex parameters, receiving arrays, and working with JDBC WebRowSet objects over the wire.

    http://roderickbarnes.com/blog/droid-chronicles-web-services-handling-complex-parameters

    There are other blog articles on working with kSOAP2 on the site. I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

These past few days I've been working toward converting my PHP code base from
from the past few days i have been following a lot of tutorials regarding
Have been learning ASP.NET (using C#) over the past few days. I have made
I have been building my own carasol over the past few days. My Jquery
For the past few days I have been attempting to write my own shell
Over the past few days, I have been trying to find an answer to
I've been working on this for the past few days and I can't find
I have been playing around with tableviews for the past few days trying to
I've been experimenting with the Android SDK over the past few days, in readiness
I am new to vista and not a advanced programmer. From past few days

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.