3

that my source code,

private static final String URL = "http://footballpool.dataaccess.eu/data/info.wso";
private static final String NAME_SPACE = "http://footballpool.dataaccess.eu";
private static final String METHODE_NAME = "TopGoalScorers";
private static final String SOAP_ACTION = NAME_SPACE + "/" + METHODE_NAME;


SoapObject request = new SoapObject(NAME_SPACE, METHODE_NAME);

    request.addProperty("iTopN", 10);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);

    envelope.setOutputSoapObject(request);

    HttpTransportSE transporte = new HttpTransportSE(URL);


    SoapObject soapObject = null;
    try {
        transporte.call("http://footballpool.dataaccess.eu/data/info.wso/TopGoalScorers", envelope);

        soapObject = (SoapObject) envelope.getResponse();

    } catch (Exception e) {
        Log.e("Soap", e.getMessage());
    }

and i give this error:

> 01-29 10:44:17.877: E/AndroidRuntime(10704): FATAL EXCEPTION: main
01-29 10:44:17.877: E/AndroidRuntime(10704): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.serviosweb/com.android.serviosweb.MainActivity}: java.lang.NullPointerException: println needs a message
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.os.Looper.loop(Looper.java:137)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread.main(ActivityThread.java:5039)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at java.lang.reflect.Method.invokeNative(Native Method)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at java.lang.reflect.Method.invoke(Method.java:511)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at dalvik.system.NativeStart.main(Native Method)
01-29 10:44:17.877: E/AndroidRuntime(10704): Caused by: java.lang.NullPointerException: println needs a message
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.util.Log.println_native(Native Method)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.util.Log.e(Log.java:231)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at com.android.serviosweb.MainActivity.onCreate(MainActivity.java:44)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.Activity.performCreate(Activity.java:5104)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-29 10:44:17.877: E/AndroidRuntime(10704):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-29 10:44:17.877: E/AndroidRuntime(10704):    ... 11 more

any one help me please

Ash Burlaczenko
  • 24,778
  • 15
  • 68
  • 99
Zouhair
  • 611
  • 2
  • 8
  • 15

4 Answers4

3

In the catch statement use:

String errorMessage = (ex.getMessage()==null)?"Message is empty":ex.getMessage();
Log.e("Message:",errorMessage );  
Raja Asthana
  • 2,080
  • 2
  • 19
  • 35
0

In the catch, use:

String err = (ex.getMessage()==null)?"SD Card failed":ex.getMessage();
Log.e("sdcard-err2:",err);  
NewStack
  • 990
  • 8
  • 19
0

Your Problem is quite simple. There is an Exception thrown inside your try Block. The Catch-Block now tries to handle these Exception, by printing the Exception message to your Log. Unlikely the message you want to print is not set, and your Logger(sys.out.print) is not capable of printing nothing (a null value).

As long as you want to print the StackTrace instead like Mohamed_AbdAllah suggested. You need to get the StackTrace as String Guava and Apache Commons have Methods for these purpose. A simple build your own way would be:

StackTraceElement[] stack = e.getStackTrace();
StringTrace = "";
for(StackTraceElement line : stack)
{
   Trace += line.toString();
}

    Log.e("Soap",Trace);
Johannes
  • 275
  • 3
  • 12
  • thank you, the result is: [Ljava.lang.StackTraceElement;@41501db8 – Zouhair Jan 29 '13 at 10:12
  • I Updated my original answer. – Johannes Jan 29 '13 at 10:20
  • thank you that is the error is so big for post it here https://www.dropbox.com/s/amhi1zn0korxu6a/error.txt – Zouhair Jan 29 '13 at 10:51
  • Now, you are facing a different Error, your real Error. I'm not in Android but i think this is maybe the answer [Link to StackOverflow](http://stackoverflow.com/questions/11277734/http-doesnt-work-in-android-emulator) – Johannes Jan 29 '13 at 12:01
0

Use this code :(For example)

        SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);

        PropertyInfo username = new PropertyInfo();
        username.setName("username");
        username.setValue("google");
        username.setType(String.class);
        username.setNamespace(NAMESPACE);
        request.addProperty(username);
A.A
  • 1,138
  • 1
  • 16
  • 29