0

这是我从服务器获取数据的代码。

public class POSDataCloud {
private static String SOAP_ACTION1 = "http://tempuri.org/GetDescription";    
private static String NAMESPACE = "http://tempuri.org/"; 
private static String METHOD_NAME1 = "GetDescription";     
private static String URL = "http://182.160.99.115:2080/webservice1.asmx?WSDL";

public String GetPOSData(int POSID)
{
    String ret="";
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME1);    
    //request.addProperty("Id",POSID);
    PropertyInfo property = new PropertyInfo();
    {
        property.name = "Id";
        property.setNamespace(NAMESPACE);
        property.type = PropertyInfo.STRING_CLASS;
        property.setValue("3"); 
    }
    request.addProperty(property);

    //Declare the version of the SOAP request   
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);           
    envelope.setOutputSoapObject(request);
    envelope.implicitTypes=true;
    envelope.dotNet = true;
    try
    {
          HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);                   
          //this is the actual part that will call the webservice
          androidHttpTransport.call(SOAP_ACTION1, envelope);          
          // Get the SoapResult from the envelope body.
          SoapObject result = (SoapObject)envelope.bodyIn;
          if(result != null)
          {
              ret=result.getProperty(0).toString();
          }
          else
          {
              ret="no response";
          }
    } 
    catch (Exception ex)
    {
      ex.printStackTrace();
      ret=ex.getMessage();
    }
    return ret;


}

}

但我想用 asyncTaskLoader 来做。怎么做?编辑:实际上 property.setValue 是 PosId。如何在 asynctaskloader 的 loadInBackground 中传递 posId?我只需要 loadInBackground 方法的实现。我认为它应该有 posId 参数。但我无法获得任何带参数的 asynctaskloader 示例loadInBackground 方法。非常感谢任何人帮助我。

4

0 回答 0