如何发送" ArrayOfString"在肥皂请求?

时间:2014-07-12 09:27:38

标签: android ksoap2 arrayofstring

我正在使用的方法是期望一个字符串数组 - 我只想发送一个与参数“attributes”相关联的值(first_name) - 它在SOAPUI中工作

SoapObject request2 = new SoapObject(NAMESPACE, METHOD_NAMEdoselect); 
request2.addProperty("sid", usersid);
request2.addProperty("objectType","cnt");   
request2.addProperty("whereClause","first_name = 'Olivia'");
request2.addProperty("maxRows",-1);
request2.addProperty("attributes","first_name");

从requestdump它显示它发送的是字符串而不是数组。如何使它成为Arrayofstring? 我似乎无法找到任何关于此的信息。

如果您需要更多信息,请告诉我们!

1 个答案:

答案 0 :(得分:1)

请尝试这种方式,希望这有助于您解决问题。

public class Array implements KvmSerializable {

    private String sid;
    private String objectType;
    private String whereClause;
    private String maxRows;
    private String attributes;

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getObjectType() {
        return objectType;
    }

    public void setObjectType(String objectType) {
        this.objectType = objectType;
    }

    public String getWhereClause() {
        return whereClause;
    }

    public void setWhereClause(String whereClause) {
        this.whereClause = whereClause;
    }

    public String getMaxRows() {
        return maxRows;
    }

    public void setMaxRows(String maxRows) {
        this.maxRows = maxRows;
    }

    public String getAttributes() {
        return attributes;
    }

    public void setAttributes(String attributes) {
        this.attributes = attributes;
    }




    @Override
    public Object getProperty(int arg0) {
        // TODO Auto-generated method stub
        switch (arg0){
            case 0:
                return sid;
            case 1:
                return objectType;
            case 2:
                return whereClause;
            case 3:
                return maxRows;
            case 4:
                return attributes;
            default:
                return null;
        }

    }
    @Override
    public int getPropertyCount() {
        return 5; //number of passing parameters
    }
    @Override
    public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
        switch(arg0)
        {

            case 0:
                arg2.type = PropertyInfo.STRING_CLASS;
                arg2.name = "sid"; 
                break;
            case 1:
                arg2.type = PropertyInfo.STRING_CLASS;
                arg2.name = "objectType";
                break;
            case 2:
                arg2.type = PropertyInfo.STRING_CLASS;
                arg2.name = "whereClause";
                break;
            case 3:
                arg2.type = PropertyInfo.OBJECT_CLASS;
                arg2.name = "maxRows";
                break;
            case 4:
                arg2.type = PropertyInfo.OBJECT_CLASS;
                arg2.name = "attributes";
                break;
            default:break;
        }
    }
    @Override
    public void setProperty(int arg0, Object arg1) {
        switch(arg0)
        {
            case 0:
                sid =  (String)arg1;
                break;
            case 1:
                objectType =  (String)arg1;
                break;
            case 2:
                whereClause =  (String)arg1;
                break;
            case 3:
                maxRows = (String)arg1;
                break;
            case 4:
                attributes = (String)arg1;
                break;

            default:
                break;
        }
    }
}

Array array = new Array();
array.setFirstname(firstname);
array.setLastname(lastname);
array.setAddress(address);
array.setCity(city);
array.setState(state);

在doInBackground中添加以下内容:

PropertyInfo pInfo = new PropertyInfo();
pInfo.setName("array");
pInfo.setValue(array);
pInfo.setType(array.getClass());

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty(pInfo);