0

The method I am using is expecting an array of string - I only want to send one value (first_name) associated with the parameter "attributes" - It works in 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");

From the requestdump it shows it's sending a string rather than an array. How do I make it an Arrayofstring? I can't seem to find any info on this.

If you need any more info just let me know!

M A
  • 71,713
  • 13
  • 134
  • 174

1 Answers1

1

Try this way,hope this will help you to solve your problem.

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);

In doInBackground add this:

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

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
request.addProperty(pInfo);
Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67
  • Could you please explain what this is doing, I tried to use it but I had to change somethings e.g. sid = int not string (same with maxrows) so its not working. I added it above my "LongOperation extends AsyncTask..." is this the right place to put it? Also where do I put Array array = new Array(); array.setFirstname(firstname); array.setLastname(lastname); array.setAddress(address); array.setCity(city); array.setState(state); I don't need city, state etc so do I just delete it? Thankyou!!! :) – user3785656 Jul 13 '14 at 00:40