Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将数组从android发送到dotnet webservice_Android_Asp.net_Web Services - Fatal编程技术网

如何将数组从android发送到dotnet webservice

如何将数组从android发送到dotnet webservice,android,asp.net,web-services,Android,Asp.net,Web Services,我有多个值要从android发送到DotNet Webservice 所有值都存储在数组中 Dotnet方法代码: [WebMethod] [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)] public void setApprovedEmp(string[] arrCheckedEmpIds) { // Use array here. } String[] arrIds = { "1009

我有多个值要从android发送到DotNet Webservice

所有值都存储在数组中

Dotnet方法代码:

[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void setApprovedEmp(string[] arrCheckedEmpIds)
{
     // Use array here.
}
String[] arrIds = { "1009", "1001", "1012" }; // Array data is dynamic, not fix size
parameters.add(new BasicNameValuePair("arrCheckedEmpIds", arrIds));
Android代码:

[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public void setApprovedEmp(string[] arrCheckedEmpIds)
{
     // Use array here.
}
String[] arrIds = { "1009", "1001", "1012" }; // Array data is dynamic, not fix size
parameters.add(new BasicNameValuePair("arrCheckedEmpIds", arrIds));
String[]arrIds={“1009”、“1001”、“1012”};

对于(int i=0;i将您的parameters对象序列化为JSON,这样您将得到如下结果:

{
    "arrCheckedEmpIds":["1009", "1001", "1012"]
}

并通过POST请求将其作为请求负载发送到您的WebMethod中,内容类型和接受头设置为“application/json”.

我如何将参数对象序列化为JSON?我不知道如何在Java/Android中实现,但我相信你会在网上找到大量的资料如何手动或使用库实现。它不起作用。当我试图在Dotnet中获取数组时,它将在数组中显示一个元素,并且第一个元素包含我需要的完整参数字符串从android发送。