如何将数组从android发送到dotnet webservice
我有多个值要从android发送到DotNet Webservice 所有值都存储在数组中 Dotnet方法代码:如何将数组从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
[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发送。