是否可以在android中为一个PropertyInfo设置多个名称和值?

时间:2013-10-30 08:26:49

标签: android web-services android-ksoap2

我正在创建可以使用soap客户端(WSDL)连接到Web服务的android应用程序。现在我想知道是否可以使用PropertyInfo创建请求并为其设置多个名称和值。我有这个代码以获取有关我的问题的更多信息。

        String METHOD_NAME = "callLog";
        String NAMESPACE = "http://sasd.logpos.com/appservs/app/customize/qwe/ecq.wsdl/";
        String URL = "http://sasd.logpos.com/appservs/app/customize/qwe/ecqsoap.php";
        String SOAP_ACTION = "http://sasd.logpos.com/appservs/app/customize/qwe/ecq.wsdl/callLog";
        Log.i("myEmpId", myEmpId);
        Log.i("myPassword", myPassword);
        //create request
        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
        //create param
        PropertyInfo paramsEmpId = new PropertyInfo();
        paramsEmpId.setName("authuserid");
        paramsEmpId.setValue(myEmpId);
        paramsEmpId.setType(String.class);


        paramsPass.setName("authpassword");
        paramsPass.setValue(myPassword);
        paramsPass.setType(String.class);
        request.addProperty(paramsEmpId, "LOGON");

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.dotNet = true;
        envelope.setOutputSoapObject(request);

        HttpTransportSE ht = new HttpTransportSE(URL);
        try {
            ht.call(SOAP_ACTION, envelope);
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e) {
            e.printStackTrace();
        }
        String response = null;
        try {
            response = envelope.getResponse().toString();
        } catch (SoapFault e) {
            e.printStackTrace();
        }

2 个答案:

答案 0 :(得分:0)

是的,您可以添加PropertyInfo

我发现您使用URL的另一个问题应该始终是WSDL网址,并检查您的Namespace

//create param
        PropertyInfo paramsEmpId = new PropertyInfo();
        paramsEmpId.setName("authuserid");
        paramsEmpId.setValue(myEmpId);
        paramsEmpId.setType(String.class);

        PropertyInfo paramsPass= new PropertyInfo();// Create a new propertyInfo
        paramsPass.setName("authpassword");
        paramsPass.setValue(myPassword);
        paramsPass.setType(String.class);
        request.addProperty(paramsEmpId);// Changed here
        request.addProperty(paramsPass); // Changed here

答案 1 :(得分:0)

       yes this possible and  hope this is going to help you

      please check the lines


 paramsPassInfo paramsPass= new paramsPassInfo();

        paramsPass.setName("authpassword");
        paramsPass.setValue(myPassword);
        paramsPass.setType(String.class);

  request.addProperty(paramsPass, "//name");