I am new to android programming and trying to use webservice in this sample program:
I use Android 4.1 and my IDE is Eclipse Juno. I think the programming part is ok
You can't do Network operations on the main thread. Checkout : http://developer.android.com/reference/android/os/AsyncTask.html
for painless background threading :)
EDIT: Since I am still getting up-votes for this answer even though it's several years old I would no longer suggest using AsyncTask. It has many known problems which are described here (http://blog.danlew.net/2014/06/21/the-hidden-pitfalls-of-asynctask/). Instead I would urge you to use Retrofit or one of the other nice http clients which handles the threading for you.