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 6807103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:47:28+00:00 2026-05-26T19:47:28+00:00

I want to pass an array from my Android application to my SOAP webservice

  • 0

I want to pass an array from my Android application to my SOAP webservice using the ksoap libraries available.

My array looks like this:

String[] values={"abc","def"};

How to pass this as a parameter to my web service call?

Can anyone please help me out ?

This is my web service code :

  public class Service1 : System.Web.Services.WebService
   {
    [WebMethod]

    public String getnames(String[] values)
    {

        try
        {

            using (SqlConnection myConnection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=student;User ID=sa;Password=123"))
            {
                int count = 1;
                int rows = 0;

                myConnection.Open();
                foreach (string student in values)
                {
                    count++;
                    using (SqlCommand myCommand = new SqlCommand())
                    {
                        myCommand.Connection = myConnection;
                        myCommand.CommandText = "insert into record values(@pCount, @pStudent)";
                        SqlParameter param = myCommand.CreateParameter();
                        param.ParameterName = "@pCount";
                        param.Value = count;
                        myCommand.Parameters.Add(param);

                        param = myCommand.CreateParameter();
                        param.ParameterName = "@pSudent";
                        param.Value = student;

                        rows = myCommand.ExecuteNonQuery();
                    }
                }
            }
        }

        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            return "an error occured";
        }


        return "success";
       }
     }
  }

my logcat :

   11-10 12:26:56.159: INFO/System.out(334):  ----null
   11-10 12:26:56.159: DEBUG/AndroidRuntime(334): Shutting down VM
   11-10 12:26:56.159: WARN/dalvikvm(334): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334): FATAL EXCEPTION: main
   11-10 12:26:56.179: ERROR/AndroidRuntime(334): java.lang.NullPointerException
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at com.example.display.call2(display.java:193)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at com.example.display$3.onClick(display.java:146)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.view.View.performClick(View.java:2408)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.view.View$PerformClick.run(View.java:8816)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.os.Handler.handleCallback(Handler.java:587)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.os.Handler.dispatchMessage(Handler.java:92)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.os.Looper.loop(Looper.java:123)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at android.app.ActivityThread.main(ActivityThread.java:4627)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at java.lang.reflect.Method.invokeNative(Native Method)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at java.lang.reflect.Method.invoke(Method.java:521)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   11-10 12:26:56.179: ERROR/AndroidRuntime(334):     at dalvik.system.NativeStart.main(Native Method)
   11-10 12:26:56.189: WARN/ActivityManager(58):   Force finishing activity com.example/.display

Thanks in advance

  • 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-26T19:47:28+00:00Added an answer on May 26, 2026 at 7:47 pm

    This is the sample code for reading SOAP web service, Hope this will help you,

    private static String SOAP_ACTION = "http://tempuri.org/HelloWorld";
    
    private static String NAMESPACE = "http://tempuri.org/";
    private static String METHOD_NAME = "HelloWorld";
    
    private static String URL = "http://bimbim.in/Sample/TestService.asmx?WSDL";
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        //Initialize soap request + add parameters
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        
    
        //Use this to add parameters
        request.addProperty("Parameter","Value");
    
        //Declare the version of the SOAP request
        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);
    
        //Needed to make the internet call
        HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
        try {
            //this is the actual part that will call the webservice
            androidHttpTransport.call(SOAP_ACTION, envelope);
        } catch (Exception e) {
            e.printStackTrace();
        }
    
        // Get the SoapResult from the envelope body.
        SoapObject result = (SoapObject)envelope.bodyIn;
    
        if(result != null){
            TextView t = (TextView)this.findViewById(R.id.resultbox);
    
            //Get the first property and change the label text
            t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
        }
    
    }
    

    Also look at

    Android Lists IV: Accessing and Consuming a SOAP Web Service I

    The Droid Chronicles – Web Services: Using kSOAP2 to Pass Complex Objects

    EDIT:

    It is a known issue with the KSOAP2 for Android library, which at the moment simply does not support arrays. The issue description is here:

    http://code.google.com/p/ksoap2-android/issues/detail?id=19

    A third-party patch, solution and an example can be found here:

    http://people.unica.it/bart/ksoap2-patch/

    Look on these link, You can find your answer on that.

    Thanks.

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

Sidebar

Related Questions

I want to pass an array of objects from my QtScript to C++ but
I want to pass a list array from the View to the controller on
I am having two activities in my application. I want to pass tha array
I am using CodeIgniter in my application. I have a code like this $this->db->where('a.PreferenceID
I want to pass an array of strings from my view model (in form
I want to pass an integer array from input parameters of my postgresql function
I want pass an array from Class A to Class B, but A calls
hello every one i want to pass the php array from the javascript function
I want to pass a 3d float array(float[][][]) from java to c edit it
I want to pass an array of arbitrary struct pointers and a comparison function

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.