0

我需要通过 android 应用程序向 webservice -asp.net- 发送多个值

这是网络服务方法

    <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 中的参数

我用了这段代码

     request.addProperty("nums", params[0]);
     request.addProperty("nums", params[1]);

但它不能正常工作......

此致

4

1 回答 1

0

我不太确定是否可以在soapobject 中使用多个具有相同名称的参数。像 request.addProperty("nums", params); 这样传递参数不是更好吗?我想这个讨论可以帮助https://groups.google.com/forum/#!topic/ksoap2-android/pq1V2ZXY3D8

于 2013-09-18T10:47:08.847 回答