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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:41:44+00:00 2026-05-26T17:41:44+00:00

I have array defined like this : ArrayList<String> items = new ArrayList<String>(); I have

  • 0

I have array defined like this :

 ArrayList<String> items = new ArrayList<String>();

I have populated that array now and I wish to send it via a web service to my remote database.

Here is the method in my Android code that does the ksoap work

  public String[] call2()
     { 
     SoapPrimitive responsesdata = null; 

     SoapObject request = new SoapObject(namespace, method_NAME);      
     request.addProperty("names",items);

     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);

        //responsesdata = (SoapPrimitive) envelope.getResponse(); 

        SoapObject result = (SoapObject)envelope.bodyIn; 

        if(result != null)
        { 
            System.out.println("SOAP response:\n\n" + result.getProperty(0).toString()); 

        }


        System.out.println(" --- response ---- " + responsesdata); 

        } catch (SocketException ex) { 
        ex.printStackTrace(); 
        } catch (Exception e) { 
        e.printStackTrace(); 
        } 

        System.out.println( " ----" + responsesdata );
        String serviceResponse= responsesdata .toString(); 
        System.out.println(serviceResponse);

        String[] temp; 
        String delimiter = ","; 
        temp= serviceResponse.split(delimiter);

        return temp; 

 }

However when I run my code I am getting Null Pointer Exception see in logcat below:

            11-10 15:22:50.496: WARN/System.err(295): java.lang.RuntimeException: Cannot serialize: []
            11-10 15:22:50.496: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:629)
            11-10 15:22:50.505: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeProperty(SoapSerializationEnvelope.java:613)
            11-10 15:22:50.515: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:582)
            11-10 15:22:50.515: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeObjectBody(SoapSerializationEnvelope.java:566)
            11-10 15:22:50.515: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeElement(SoapSerializationEnvelope.java:623)
            11-10 15:22:50.515: WARN/System.err(295):     at org.ksoap2.serialization.SoapSerializationEnvelope.writeBody(SoapSerializationEnvelope.java:547)
            11-10 15:22:50.515: WARN/System.err(295):     at org.ksoap2.SoapEnvelope.write(SoapEnvelope.java:192)
            11-10 15:22:50.525: WARN/System.err(295):     at org.ksoap2.transport.Transport.createRequestData(Transport.java:74) 
            11-10 15:22:50.555: INFO/System.out(295):  ----null
            11-10 15:22:50.565: DEBUG/AndroidRuntime(295): Shutting down VM
            11-10 15:22:50.565: WARN/dalvikvm(295): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
            11-10 15:22:50.586: ERROR/AndroidRuntime(295): FATAL EXCEPTION: main
            11-10 15:22:50.586: ERROR/AndroidRuntime(295): java.lang.NullPointerException
            11-10 15:22:50.586: ERROR/AndroidRuntime(295):     at com.example.display.call2(display.java:200)
            11-10 15:22:50.586: ERROR/AndroidRuntime(295):     at com.example.display$3.onClick(display.java:145)
            11-10 15:22:50.586: ERROR/AndroidRuntime(295):     at android.view.View.performClick(View.java:2408)

My web service code:

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

      public String getnames(String[] values)
      {

        try
         {

            using (SqlConnection myConnection = new SqlConnection(@"Data S  ource=.\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";
       }
    } 
 }
  • 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-26T17:41:45+00:00Added an answer on May 26, 2026 at 5:41 pm

    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 have an array of strings defined like this: char** arrNames; Now I want
An array is defined of assumed elements like I have array like String[] strArray
I have an array defined like this, result = [true,false,false,false] In my code I
I have a struct named Game with an array of levels, defined like this:
Lets say I have a array defined in Groovy like this def int[] a
If I have a javascript object/assoc. array defined like this: function somefunction(options) { var
I have javascript object defined like this: function SocialMiner() { var verbose=true; var profileArray=new
I have some Javascript code that acts on an pixel array defined like so:
I have a Java array defined already e.g. float[] values = new float[3]; I
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>

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.