Hello everyone. I am parsing the following type of response using the Ksoap2 library, but I am not getting success to get the result. My request is as follows:
<soapenv:Header/> <soapenv:Body> <tem:Register> <tem:user> <jir:Area>testArea</jir:Area> <jir:AvailableBalance>0</jir:AvailableBalance> <jir:CityId>1</jir:CityId> <jir:Email> test@test.com </jir:Email> <jir:FullName></jir:FullName> <jir:Gender>M</jir:Gender> <jir:Mobile>111111111</jir:Mobile> <jir:Password>acxcsgsdvs</jir:Password> <jir:Phone>111111111</jir:Phone> <jir:SecurityAnswer>testQ</jir:SecurityAnswer> <jir:SecurityQuestion>TestAb</jir:SecurityQuestion> <jir:Username>sdf</jir:Username> </tem:user> </tem:Register> </soapenv:Body>
using the ksoap2 library, I successfully created this answer:
Register{user{Area=test; AvailableBalance=150; CityId=1; Email=test@test.com ; FullName=Priyank; Gender=M; Mobile=9909957148; Password=testp; Phone=9909957148; SecurityAnswer=MyAns; SecurityQuestion=MyQues; Username=t; }}
but my problem is that my values ββare not added to the user tag, so I get an exception:
Object reference not set to an instance of an object.
please give an answer to this, how can I parse this type of answer using the ksoap2 library.
This is my helper class that I use to parse the answer:
public class KSOAPHelper { private static final String TAG = "KSOAPHelper : KSOAP Helper"; private static final String SOAP_ACTION = "http://tempuri.org/IUserService/"; private static final String NAMESPACE = "http://tempuri.org/"; private static final String URL = "my url" // Method names public static final String REGISTER = "Register"; public static final String LOGIN = "Login"; public static final String LOGOUT = "Logout"; public static final String PROFILEDETAILS = "ProfileDetails"; public static Object getResponce(LinkedHashMap<String, String> inputParams, String methodName, final Context context) { if (Utility.isConnectionAvailable) { final String soap_action = SOAP_ACTION + methodName; Log.d(TAG, soap_action); SoapObject request = new SoapObject(NAMESPACE, methodName); SoapObject user = new SoapObject(NAMESPACE, "user"); for (String param : inputParams.keySet()) { Log.d(TAG, param + " : " + inputParams.get(param)); user.addProperty(param, inputParams.get(param)); } request.addSoapObject(user); Log.d(TAG, "SOAP Request : " + request); /* * Set the web service envelope */ SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); soapEnvelope.dotNet = true; // soapEnvelope.implicitTypes = true; soapEnvelope.setOutputSoapObject(request); HttpTransportSE httpTransportSE = new HttpTransportSE(URL); try { httpTransportSE.call(soap_action, soapEnvelope); if (soapEnvelope.bodyIn instanceof SoapFault) { String strFault = ((SoapFault) soapEnvelope.bodyIn).faultstring; Log.v(TAG, "Fault string : " + strFault); } else { Object object = soapEnvelope.getResponse(); return object; } } catch (Exception e) { if (e instanceof SocketException || e instanceof IOException) { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { } }); } } e.printStackTrace(); } } else { if (context instanceof Activity) { ((Activity) context).runOnUiThread(new Runnable() { @Override public void run() { } }); } Log.d(TAG, "Internet Connection is not available"); } return null; }
source share