TechAid24

Your Technical Consultant

SOAP Web Services in Android: Working with SoapObject and SoapPrimitive

Posted on by Selim Ahmed 1 minute read

SoapObject is used when we need to get the Response for a Class type, like Customer, Product, etc. (From the SoapObject you need to iterate over the values inside the SoapResponse.) SoapPrimitive is used for Primitive datatypes like Integer, and Boolean.

For example, in the following code I am expecting a Boolean value from SoapResponse:

SoapPrimitive response = (SoapPrimitive) envelope.getResponse();
Boolean status = Boolean.valueOf(response.toString());

And in the following code, I need to get the Response as an Object:

SoapObject response = (SoapObject) envelope.getResponse();
Log.d("Response", response.toString());
int count = response.getPropertyCount();

for (int i = 0; i < count; i++) {
    userObj = new User(response.getProperty(1).toString(),
                       Double.parseDouble(response.getProperty(2).toString()));  
}

Tags:

Selim Ahmed

Thank you for visiting my personal blog. I’m Selim Ahmed, a tech-savvy who loves to learn a new technology every day. Innovation, research, and development is my daily activities. I love to work in a place where I can learn, innovate, and develop new things.Please feel free to reach me on any comments and feedback you have. I would be more than glad to listen and reply.

Leave a Reply

Your email address will not be published. Required fields are marked *