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

  • Home
  • SEARCH
  • 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 9109119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:58:00+00:00 2026-06-17T02:58:00+00:00

My webservice; [WebMethod] public int insertNhanVien(string[] arr) { SqlConnection con = new SqlConnection(); //

  • 0

My webservice;

[WebMethod]
    public int insertNhanVien(string[] arr)
    {

        SqlConnection con = new SqlConnection();
        // con.ConnectionString = "Data Source=.\\SQLEXPRESS;Initial Catalog=Bai1;Integrated Security=True";
        con.ConnectionString = "server=.\\SQLEXPRESS;database=QLNV;uid=sa;pwd=123456";
        con.Open();
        int n = 0;
        for (int i = 0; i < arr.Length; i++)
        {
            string[] s = arr[i].ToString().Split(',');

            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Insert Into MUser(Ten,Tuoi) values(" + s[0].Replace("'", "''") + "," + s[1] + ")";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;

            n = cmd.ExecuteNonQuery();
        }
        return n;
    }

And code in android:

private boolean insertNhanVient() {
        boolean result = false;
        try {

            String NAMESPACE ="http://tempuri.org/";
            String METHOD_NAME ="insertNhanVien";
            String URL ="http://localhost:10829/WebSite/Service.asmx";
            String SOAP_ACTIONS = NAMESPACE + "/" + METHOD_NAME;
            SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
            String [] arr =new String[3];
            arr[0]="le,12";
            arr[1]="hoang,33";
            arr[2]="nhung,23";
            request.addProperty("arr", arr);

            SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                    SoapEnvelope.VER11);

            envelope.dotNet=true;
            envelope.setOutputSoapObject(request);
            HttpTransportSE androidhttpTranport = new HttpTransportSE(URL);

            try {
                androidhttpTranport.call(SOAP_ACTIONS, envelope);
            } catch (IOException e3) {              
                result = false;

            } catch (XmlPullParserException e3) {

                result = false;
            }
            Object responseBody = null;
            try {
                responseBody = envelope.getResponse();
                String t = responseBody.toString();
                if (t.equals("1")) {
                    result = true;
                }
            } catch (SoapFault e2) {

                result = false;
            }
        } catch (Exception e) {

            result = false;
        } finally {
        }
        return result;
    }

Why show exception: java.lang.RuntimeException: Cannot serialize: [Ljava.lang.String;@4051d0a0 ?

  • 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-06-17T02:58:02+00:00Added an answer on June 17, 2026 at 2:58 am

    you can’t pass whole array.. so you have to use seprator @@ in String ..and pass it service… and change on service respectivley.

    String commasepratedString="";
    for(int i=0;i<arr.length();i++)
    {
    if(i!=(arr.length-1)) 
    {
    commasepratedString=commasepratedString+arr[i]+"@@";
    }
    else
    {
    commasepratedString=commasepratedString+arr[i];
    }
    }
    
     request.addProperty("arr", commasepratedString);
    

    and change service code like this way

    [WebMethod]
    public int insertNhanVien(string commasepratedString)
    {
        String arr[] = commasepratedString.Split('@@');
        SqlConnection con = new SqlConnection();
        // con.ConnectionString = "Data Source=.\\SQLEXPRESS;InitialCatalog=Bai1;          Integrated Security=True";
        con.ConnectionString = "server=.\\SQLEXPRESS;database=QLNV;uid=sa;pwd=123456";
        con.Open();
        int n = 0;
        for (int i = 0; i < arr.Length; i++)
        {
            string[] s = arr[i].ToString().Split(',');
    
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "Insert Into MUser(Ten,Tuoi) values(" + s[0].Replace("'", "''") + "," + s[1] + ")";
            cmd.CommandType = CommandType.Text;
            cmd.Connection = con;
    
            n = cmd.ExecuteNonQuery();
        }
        return n;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following webservice: [webmethod] public string MakeReservation(?? PassengersInfo)//what data type use for PassengerInfo
i have webservice with one method which recieves xml as string: [WebMethod] public int
am accessing a class from my webservice as [WebMethod(EnableSession = true)] public string fetchAbsentees(string
I'm using C# webservice in my webMethod: [WebMethod] public SignUpResponse SignUp(string email, string password)
I have webservice, with method: [WebMethod] public byte[] GetFile(string FName) { System.IO.FileStream fs1 =
i've got the following simple webservice : [WebMethod()] public int Add(int a) { return
I have one webservice: public class Product { public int ProductId { get; set;
i have a webmethod in my webservice public class Service : System.Web.Services.WebService { [WebMethod]
Ii have a web method that looks like this: [WebMethod] public int ImportData(System.Collections.Generic.List<Record> importRecords)
I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer()

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.