我需要通过Android应用程序将多个值发送到webservice -asp.net-
这是webservice方法
<WebMethod()> _
Public Function AddTheNums(ByVal nums() As String,) As String
For i = 0 To nums.Length - 1
--some process
Next
Return status
End Function
我在android中使用此代码
public class Login extends AsyncTask<String, Void, String>
{
public Login(String MethodName)
{
}
public void onPreExecute()
{
}
@Override
protected String doInBackground(String... params)
{
final SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty("nums", params[0]);
request.addProperty("nums", params[1]);
final SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
envelope.dotNet = true;
try
{
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.call(SOAP_ACTION, envelope);
SoapPrimitive result = (SoapPrimitive) envelope.getResponse();
response = result.toString();
}
return response;
}
@Override
public void onPostExecute(String res)
{
}
}
任何人都可以帮助我,我需要向webserive中的参数发送多个nums
我使用了这段代码
request.addProperty("nums", params[0]);
request.addProperty("nums", params[1]);
但它无法正常工作......
最好的问候
答案 0 :(得分:0)
我不确定在soapobject中可以使用多个具有相同名称的参数。传递param是不是更好 request.addProperty(“nums”,params); 我想这个讨论可以帮助https://groups.google.com/forum/#!topic/ksoap2-android/pq1V2ZXY3D8