kvin024 / ksoap2-android

Automatically exported from code.google.com/p/ksoap2-android
0 stars 0 forks source link

HttpTransportSE.call method returns NullPointerException frequently #151

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Set NAMESPACE AND METHOD_NAME to SoapObject and add required properties.
2.Wrap soap object in envelope
3.Make the call with the envelope
4.Catches NullPointerException at the call method 'FREQUENTLY', not always.

What is the expected output? What do you see instead?
To establish connection parameters to begin communicating with the server 
hosting the web service.

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.

My calling code is :

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

request.addProperty("data", "value");

SoapSerializationEnvelope envelope = new 
SoapSerializationEnvelope(SoapEnvelope.VER12);

envelope.dotNet = true;
envelope.setOutputSoapObject(request);

try{
    HttpTransportSE http = new HttpTransportSE(URL);
    http.debug = true;
    System.setProperty("http.keepAlive", "false");

    http.call(SOAP_ACTION, envelope);
}catch (Exception e) {
    Log.w("Exception", e.toString());
}

Original issue reported on code.google.com by rbhhere on 6 Feb 2013 at 5:28

GoogleCodeExporter commented 9 years ago
Try with 3.0.0

Original comment by mosa...@gmail.com on 5 Mar 2013 at 7:50

GoogleCodeExporter commented 9 years ago

Original comment by mosa...@gmail.com on 5 Mar 2013 at 7:50

GoogleCodeExporter commented 9 years ago
Yes  I used 3.0.0 RC4. . problem is fixed. You can close it then I guess 

Original comment by rbhhere on 17 Apr 2013 at 12:28

GoogleCodeExporter commented 9 years ago

Original comment by mosa...@gmail.com on 17 Apr 2013 at 3:45

GoogleCodeExporter commented 9 years ago
when trying to call webservice from android using HttpTransportSE.call method, 
getting NullPointerException frequently. 
Used ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar

Original comment by suma.ven...@gmail.com on 24 Jun 2013 at 12:53

GoogleCodeExporter commented 9 years ago
I also had the same issue. It happens when the server traffic is at its peak. 
At other times, it works fine. To overcome it, I enclosed the call() method in 
a loop which will loop itself 'N' times till it returns a valid SOAP object

Original comment by raba...@c2info.com on 25 Jun 2013 at 5:04

GoogleCodeExporter commented 9 years ago
int loopCount = 0, retryCount = 5;
while ( resultString.equalsIgnoreCase("serverError") && loopCount < retryCount) 
{

try{
    HttpTransportSE http = new HttpTransportSE(URL, 120000);
    http.debug = true;
    System.setProperty("http.keepAlive", "false");
    http.call(SOAP_ACTION, envelope);
}catch (IOException e1) {
    Log.w("IOException" ,  e1.toString());          
    resultString = "serverError";
} catch (XmlPullParserException e1) {
    Log.w("XmlPullParserExc for index no :" , values[3] + " " + e1.toString());
    resultString = "serverError";
} catch (Exception e) {
    Log.w("Exception for index no :" , values[3] + " " + e.toString());     
    resultString = "serverError";
}

if(!resultString.equalsIgnoreCase("serverError")) {
    SoapPrimitive soapResult = null;
    try{
        soapResult = (SoapPrimitive)envelope.getResponse();
    }catch (SoapFault e) {
        Log.w("SoapFaultExc" ,  e.toString());
        resultString = "serverError";
    }

    if(soapResult != null){
        resultString = soapResult.toString();
    } else {
        Log.w("resultString  for index no " + values[3], "serverError");
                    resultString = "serverError";

    }
}

loopCount += 1;
}

Original comment by raba...@c2info.com on 25 Jun 2013 at 10:00

GoogleCodeExporter commented 9 years ago
Good job. I have the same approach and it works fine. 

Original comment by mosa...@gmail.com on 25 Jun 2013 at 2:59