Search code examples
androidparsingsoapandroid-ksoap2

How to parse soap response from soap object?


How to parse the below soap response. particularly for the response "Result". Please help me on this. Thanks in advance.

ResponseDump

     <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
            <soap:Body>
        <RegisterWithEmailIdResponse xmlns="http://tempuri.org/"><RegisterWithEmailIdResult>
<RegisterWithEmailId xmlns="">
                <RegisterWithEmailId>
    <Result>1</Result>
</RegisterWithEmailId>
    </RegisterWithEmailId>
</RegisterWithEmailIdResult>
        </RegisterWithEmailIdResponse>
        </soap:Body>
        </soap:Envelope>

Actual response

anyType{RegisterWithEmailId=anyType{Result=1; }; }


Solution

  • Finally got it

    anyType{RegisterWithEmailId=anyType{Result=1; }; }

    You have to parse the above soap response as follows

    SoapObject res;
                    try {
                        res = (SoapObject) result
                                .getProperty("RegisterWithEmailIdResult");
                        res = (SoapObject) res.getProperty("RegisterWithEmailId");
                        res = (SoapObject) res.getProperty("RegisterWithEmailId");
                        state = res.getPropertyAsString(0).toString();
    
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }