Thursday, 19 February 2015

KSoap2 is not returning valid xml?



I am trying to get an xml data from web service. The xml data is like this



<Result>
<ErrorCode>0</ErrorCode>
<ErrorMessage>Login was succesful.</ErrorMessage>
<AuthCode>maneen90234</AuthCode>
</Result>


But what i am getting from KSoap 2 is the following String



anyType{Result=anyType{ErrorCode=1; ErrorMessage=Incorrect Username or Password; };


These is how I am calling web service



private String callAPI(String user, String password) {
request = new SoapObject(NAME_SPACE, "UserLogin");
PropertyInfo pi = new PropertyInfo();
addProperty(pi, request, "UserId", user, String.class);
addProperty(pi, request, "Password", password, String.class);
envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;

envelope.setOutputSoapObject(request);

androidHttpTransport = new HttpTransportSE(url);

try {
androidHttpTransport.call(SOAP_ACTION, envelope);
response = envelope.getResponse().toString();
} catch (Exception exception) {
response = exception.toString();

}
return response;
}

private void addProperty(PropertyInfo pi, SoapObject request, String UserId, String value, Object type) {
pi = new PropertyInfo();
pi.setName(UserId);
pi.setValue(value);
pi.setType(type);
request.addProperty(pi);
}


I have tried various answers available on SO, to no avail. Any idea what am I doing wrong here?


No comments:

Post a Comment