What steps will reproduce the problem? 1.I send a Soap-Request to my Webservice 2.The Webservice send me a response 3.httpresponsedump contains the full and valid response 4.envelope.bodyin is null
What is the expected output? What do you see instead? getting anything returned when using envelope.getResponse()
java.lang.NullPointerException at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521)
What version of the product are you using? On what operating system? ksoap2-android-assembly-2.6.5-jar-with-dependencies.jar
Please provide any additional information below.
Comment #1
Posted on Jul 11, 2012 by Helpful ElephantHere ist my code to call it:
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
//adding request.addAttribute
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.setOutputSoapObject(request); envelope.setAddAdornments(false); envelope.dotNet = true; HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); androidHttpTransport.debug = true; try { androidHttpTransport.call(SOAP_ACTION, envelope); } catch (Exception e) { e.printStackTrace(); } System.out.println(androidHttpTransport.requestDump); //The valid Response System.out.println(envelope.bodyIn); //null envelope.getResponse(); //NullpointerException
Comment #2
Posted on Jul 16, 2012 by Swift HippoDont use bodyIn... use getResponse instead.
Comment #3
Posted on Jul 16, 2012 by Helpful ElephantAs i said, envelope.getResponse() is throwing a NullpointerException, not even returning null. So using it wont work obviously
Comment #4
Posted on Jul 16, 2012 by Swift Hippocan you attach a stack trace with the NPE?
Comment #5
Posted on Jul 16, 2012 by Swift Hippo(No comment was entered for this change.)
Comment #6
Posted on Jul 18, 2012 by Helpful ElephantSure, this is is: Caused by: java.lang.NullPointerException at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521)
Comment #7
Posted on Jul 18, 2012 by Swift HippoThat npe is becuase bodyIn is null. Your responseDump must be null.. so you are not actually getting a response from your server at all. Try the requestDump with a debug tool like SoapUi and see what you get.
Comment #8
Posted on Jul 18, 2012 by Helpful ElephantThe Point is, the ResponseDump is not null, there i find the valid Response. SoapUI also returns the valid Response.
Comment #9
Posted on Aug 24, 2012 by Swift HippoI am not sure. Can you debug into the library and see what is wrong?
Comment #10
Posted on Jan 15, 2013 by Grumpy LionStruggling with the same problem:( Using ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar
Comment #11
Posted on Jan 15, 2013 by Grumpy LionGuys, try to set System.setProperty("http.keepAlive", "false"); in your code it might help solving the issue.
Comment #12
Posted on Jan 28, 2013 by Helpful Hippowhere should we set the propery "http.keepAlive"
Comment #13
Posted on Jan 29, 2013 by Grumpy LionBefore you execute your connection code.
Comment #14
Posted on Jan 29, 2013 by Helpful HippoHere is my connection code : try{ HttpTransportSE http = new HttpTransportSE(URL, 10000); http.debug = true; System.setProperty("http.keepAlive", "false"); //System.setProperty("http.keepAlive", "false"); http.call(SOAP_ACTION, envelope); }catch (IOException e1) { e1.printStackTrace(); Log.v("IOException", e1.toString()); return "serverError"; }catch (XmlPullParserException e1) { e1.printStackTrace(); Log.v("XmlPullParserException", e1.toString()); return "serverError"; }catch (Exception e) { Log.v("Exception", e.toString()); return "serverError"; }
Guess setProperty("http.keepAlive", "false") doesn't fix it. Still catches nullPointerException, not always, but some times.
Comment #15
Posted on Feb 5, 2013 by Massive CamelI had the same problem.. :( ... I've readed that network calls must be executed in new thread..
Source:
Comment #16
Posted on Feb 6, 2013 by Helpful Hippoof course, network calls cannot be made in the UI thread. But this problem still persists.
Comment #17
Posted on Mar 26, 2013 by Happy LionComment deleted
Comment #18
Posted on Mar 26, 2013 by Happy CatI had exactly the same issue.
Description of the issue : - When server send back a faultcode that I have created, Android application catch an IOException, then in this case envelope.bodyIn is null and Exception is HTTP request failed, HTTP status: 500 (With version ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar ) but, everything working fine with the version (ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar)
Comment #19
Posted on Aug 8, 2013 by Swift CatHi,
I'm getting the same problem.
The code works for a little times, and after that it's getting NullPointerException at org.ksoap2.serialization.SoapSerializationEnvelope.getResponse(SoapSerializationEnvelope.java:521)
This is my code: String ws = "UtilWS"; SoapObject soap = new SoapObject(URL_SOAP, "verificaDisponibilidade");
Object retorno = null;
// Cria o envelope com o objeto SOAP
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(soap);
// Cria o HttpTransport para enviar os dados (SOAP)
if(URL == null){
URL = getURL();
}
MyHttpTransport httpTransport = new MyHttpTransport(URL + ws, timeout);
try {
httpTransport.call("", envelope);
retorno = envelope.getResponse();
httpTransport.reset();
if (retorno != null) {
return true;
} else {
return false;
}
} catch (Exception e){
System.out.println("[SYNC] [ERRO] Exception no verificaDisponibilidade: " + e.getMessage());
e.printStackTrace();
return false;
}
When it works, this is my bodyIn: verificaDisponibilidadeResponse{return=MQ==; } When it doesn't work, this is my bodyIn: null
I don't know why stop to work, I didn't anything, just my sync service, without any new data to sync, just checking if have something new.
Sometimes works for an hour, sometimes the problem happens with 10 minutes.
Comment #20
Posted on Aug 28, 2013 by Grumpy HippoI've have the same issue (ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar). An exception is raised in HttpsTransportSE.Call()(for example with invalid login credentials). The strange part of this when catching this exception it's null! Than when calling the pEnvelope.getResponse() will raise a null pointer exception.
The responseDump attribute of HttpsTransportSE is not null and is including the fault reason. But the envelope attributes bodyIn and headerIn are both null.
It's not possible to determine the reason why something is going wrong beacuse the exception is null and could not be cast to SoapFault. Maybe it has something to do with the exception type?
public Object call(String pAction, SoapSerializationEnvelope pEnvelope) {
mEnvelope = pEnvelope;
if (mKeyStore != null) {
setDebug(true);
}
if (mUserName != null && mPassword != null) {
pEnvelope.headerOut = addHeaders(mUserName, mPassword);
}
try {
// Android 4.1 mobile connection disconnects on some mobile phones fix: override Connection paramater value
// "close"
List<HeaderProperty> headerList = new ArrayList<HeaderProperty>();
headerList.add(new HeaderProperty("Connection", "keep-alive"));
mHttpsConnection.call(pAction, pEnvelope, headerList);
} catch (Exception pException) { //This one is null!
Log.e(getClass().getSimpleName(), "Error occured during SOAP call");
if (pException != null) { // TODO
pException.printStackTrace();
}
if (e instanceof SoapFault) {
mFaultCode = (SoapFault) e;
}
return;
}
return pEnvelope.getResponse();
}
Comment #21
Posted on Sep 11, 2013 by Happy DogI had same problem with version 3.0.0 (ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar).
My problem got resolved when I moved back to version 2.6.0 (ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar)
Comment #22
Posted on Sep 11, 2013 by Helpful HippoUsing ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies and enclosing the call() method in a while loop solved the problem for me. - Iterate the call method 'n' times till you get a valid response.
Comment #23
Posted on Sep 24, 2013 by Happy RabbitYes I was facing same issue with ksoap2-android-assembly-3.0.0-jar-with-dependencies after that I have tried previous version and its was working for me
Comment #24
Posted on Oct 4, 2013 by Helpful WombatHello every body i have the same problem, can you helpme please)
Comment #25
Posted on May 26, 2014 by Happy OxHey Guys I have same problem we need help
Comment #26
Posted on May 27, 2014 by Happy RabbitHello,
Use this attached latest 3.3.0 jar file, your issue will be resolved.
Just let me know weather its resolved or not...
Comment #27
Posted on May 27, 2014 by Grumpy HippoIt's a little while ago, but to solve the issue that the exception is null, is to put your break point after the line with the catch statement and not put it on the same line. So put the breakpoint at the first statement after the open curly bracket of the catch block. Than the Exception isn't null anymore.
Apparently, it has something to do with the debugger.
Comment #28
Posted on Jul 2, 2014 by Massive Pandathank you thank you !!!!!!!!
use ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar :D
it works ♥ ♥
Comment #29
Posted on Apr 2, 2015 by Massive Lionit is not working with ksoap2-android-assembly-3.3.0-jar-with-dependencies.jar :(
Comment #30
Posted on Jul 28, 2015 by Quick Rabbithow to check status codes in ksoap
Comment #31
Posted on Aug 7, 2015 by Swift HippoThe project is migrating to github. If you believe this issue is still valid and should be tracked please file a new issue at https://github.com/simpligility/ksoap2-android/issues
Status: AwaitingContribution
Labels:
Type-Defect
Priority-Medium