In this post I'm going to illustrate how we can access web service in Android using ksoap2-android project that provides a lightweight and efficient SOAP library for the Android platform.
You can download the jar file from following link;
Here is the sample code that illustrate SOAP web service call. I have access a live web service ConvertWeight from http://www.webserviceX.NET/ which convert weight from one unit to another. I have set "envelope.dotNet = true;" in Line 53 since I'm accessing .NET web service. You can comment that line if your web service is not .NET one.
package com.sencide; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.PropertyInfo; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapPrimitive; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.widget.TextView; public class AndroidWebService extends Activity { private final String NAMESPACE = "http://www.webserviceX.NET/"; private final String URL = "http://www.webservicex.net/ConvertWeight.asmx"; private final String SOAP_ACTION = "http://www.webserviceX.NET/ConvertWeight"; private final String METHOD_NAME = "ConvertWeight"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); String weight = "3700"; String fromUnit = "Grams"; String toUnit = "Kilograms"; PropertyInfo weightProp =new PropertyInfo(); weightProp.setName("Weight"); weightProp.setValue(weight); weightProp.setType(double.class); request.addProperty(weightProp); PropertyInfo fromProp =new PropertyInfo(); fromProp.setName("FromUnit"); fromProp.setValue(fromUnit); fromProp.setType(String.class); request.addProperty(fromProp); PropertyInfo toProp =new PropertyInfo(); toProp.setName("ToUnit"); toProp.setValue(toUnit); toProp.setType(String.class); request.addProperty(toProp); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); envelope.dotNet = true; envelope.setOutputSoapObject(request); HttpTransportSE androidHttpTransport = new HttpTransportSE(URL); try { androidHttpTransport.call(SOAP_ACTION, envelope); SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); Log.i("myApp", response.toString()); TextView tv = new TextView(this); tv.setText(weight+" "+fromUnit+" equal "+response.toString()+ " "+toUnit); setContentView(tv); } catch (Exception e) { e.printStackTrace(); } } }
You have to add INTERNET permission to AndroidManifest.xml as follows;
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.sencide" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".AndroidWebService" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> <uses-permission android:name="android.permission.INTERNET"></uses-permission> </manifest>
You can download the source code of above project (Password:sara).
I have updated my previous code in the post Android Login Screen Using HttpClient to authenticate users from web service. There I have illustrated how you can start new activity if the login is successful.
You can download the updated source code with sample .NET web service application (Password:sara).
works well dude !! gr8 code ! :-)
ReplyDeleteplz help me
ReplyDeletei done webservices in net and want to pass in android.i m nt understanding which webserbvices i want to use for my project.Please give reply ASAP.it is helpful for my project
Thanks in adv
@Mamatha,
ReplyDeleteI didn't get your question, here I have illustrate how you can call a web service using android. In your web service you can do any task according to the requirement.
Please tell me your requirement.
Thanks !
i have problem accessing web service in android can u help me
ReplyDelete@siddhesh,
ReplyDeleteYes, please tell me your problem.
Is it possible to commucate with WCF service by these steps?
ReplyDeleteI am not able to configure SOAP_ACTION, METHOD_NAME and other strings :(
Saranga, your sample app was just what I was looking for. I have a lot of experience with .net web services but I am new to the Android platform. I have looked at a lot of samples that are out there for KSOAP2 but none of them seemed to work as promised. Yours was straight forward and works perfectly. Thanks so much for taking the time to post this. Ken
ReplyDeleteHi,
ReplyDeleteThanks for sharing this article.
May I know what should I do with the jar file & how to do it?
Cheers,
Samuel
@ KRock,
ReplyDeleteI'm so happy to hear that, Glad I could help brighten your day. :)
@ Samuel Limawan,
ReplyDeleteFirst create new folder called "lib" in your project and copy the jar file to that folder.
Then right click on your project and select Build Path --> Configure Build Path...
Then go to Libraries tab and click "Add External Jars..." button.
Then browse the jar file from the created "lib" file. That's it. :)
Check my following post and there you can see screen-shots.
Hibernate Tutorial for Beginners
Hi Saranga,
ReplyDeleteThank you very much for your answer.
I have one more question :
How to access secured asp.net webservice that requires user name & password?
This is an example of secured method.
_
_.
Public Function HelloWorld12() As String.
If Authentication.Username = "user name" And Authentication.Password = "password" Then.
Return "Hello World 12".
Else.
Return "Access Denied..."
End If.
End Function.
Thanks,
Samuel
Saranga,
ReplyDeleteI was successful running your original sample call that called
the web service http://www.webservicex.net/ConvertWeight.asmx. However when I try to call the same
(basically the same) service running on my localhost I get the dreaded "expected START_TAG"... blah blah blah error.
I saw your other sample, authenticatedUser, was running agaist localhost so I download that sample and got the same error.
I've tried every hint I can find on the net for solving this problem
1) I set the service to use local IIS Web Server in visual studio
2) I tried my local IP address in leiu of localhost
3) I tried using 10.0.2.2
None of these work when I try and access a service running on my local server.
How on earth did you get localhost to work?
Ken (KRock)
@ Samuel Limawan,
ReplyDeletePlease check the following post.
There I have created login screen. Updated code which use web service is available at the end of this post.
@ Ken,
Please check following things, make sure you have define these things correctly and these are case sensitive.
private final String NAMESPACE = "http://tempuri.org/";
private final String URL = "http://10.0.2.2:50761/Service1.asmx?WSDL";
final String SOAP_ACTION = "http://tempuri.org/ConvertWeight";
final String METHOD_NAME = "ConvertWeight";
If you are getting error please send me your code with web service project. My gmail id is saranga.rathnayake
Thanks !
I have the exact same error as Ken, please could you help me to know which are the fields to put in METHOD_NAME, URL, NAMESPACE and SOAP_ACTION??? My route to the webservice is this one:
Deletehttp://caracasfutbolclub.com/esite/images/mobil/webservice/Service1.asmx
And the method that I want to read is GetNews.
I am assuming that this is the problem for the expected Start_Tag error. Could be anything else? Thanks in advance Saranga
Saranga,
ReplyDeleteI am going to email you the AndroidLogin sample instead of the ConvertWeight sample.
In that one I downloaded your web service code and the android code.
I was able to get that sample to work when I installed the web service on another machine
running IIS on my network. You will see a comment in the web service that shows the URL
I used that worked fine.
The problem I have is I cannot get the same sample to work when I use my local IIS (localhost or 10.0.2.2).
I hope you can figure this out. While working with another server is acceptable for me it would make development
much easier and quicker if I could use localhost when testing.
Thanks again for your help.
Ken (KRock).
Very useful example, thank you for sharing
ReplyDelete@ Igor Paunov,
ReplyDeleteThanks for your comment.
hi
DeleteThis is the Best Example of How Acess .Net Webservice With Android.
ReplyDeleteThanx Bro For Posting this example ..
@ Jimmy Alex,
ReplyDeleteThank you very much for your comment.
@ Piyush Angre,
ReplyDeleteYou are welcome and I'm happy if it helps you.
can you teach me the code line by line because i dont understand the code
DeleteSaranga,
ReplyDeleteI have same problem as kRock.
The local web service returns 0 for addition of 2 numbers but same service hosted over the internet works properly.
thanks.
Please send me your code with web service, my gmail ID is saranga.rathnayake.
Deletehello dear,
ReplyDeletewhen run the above code the emulator says application has stopped.
please help me immediately.
thanks bro...
hello dear,
ReplyDeletewhen run the above code the emulator says application has stopped.
please help me immediately.
thanks bro...
@ vineet,
ReplyDeleteCan you please tell me what is the exception you can see in the error Log ?
Thank You !
hello dear,
ReplyDeleteI had remove this problem.
Its my fault.
thank you for your response.
Good working and thanks for sharing this knowledge.
@ vineet,
ReplyDeleteNo problem :)
Tnx Bro.....!!
ReplyDeletehi sir,
ReplyDeleteactually i want to connect the sql server with the xml file of android application.through which i can retrive data from the sql server database and view it in xml layout.. can u pls explain how to do this with example code???
Thank u.
Hi aiya..
ReplyDeleteI have followed your blog post create-simple-web-service-in-visual 2010. I followed this document also. My problem is I tried to connect the web service which is in your previous tutorial(Creating a simple webservice). I configured it as follow...
public final String NAMESPACE = "http://tempuri.org/";
public final String URL = "http://localhost:5424/Service1.asmx";
public final String SOAP_ACTION = "http://localhost:5424/simpleMethod";
public final String METHOD_NAME = "simpleMethod";
Is there any thing wrong..? Tnx in advance
Hello dear,
ReplyDeleteHow make php webservices and access through android.
please help me with basic example.
Thanks in advance.
Hey i need to authenticate the user with my website how to do this?
ReplyDeleteHello Saranga. that is a very nice tutorial. and thank you for this. but i have a question. how can i access the wsdl? and it says "To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntaxL svcutil.exe https://test-service.com/Service.svc?wsdl, thank you again.
ReplyDeletewell dude its working well...
ReplyDeletebut i want know that wsdl file generates through manually or auto generated by the server in this example u show only the rendering the data from server well but i have doubt that wsdl will generate from server side or what??? can i do the same thing for all to render the data from server.
can u aloberate for me???
thks in advance
This is vary useful for me thank sir
ReplyDeleteyou are welcome...
DeleteThis is very useful for me for calling web Service
ReplyDeletethanks for commenting...
Deletehi, your blog has help me a lot, but i wanted to ask you if you had a Login that uses information of a Data Bases to enter another page? thanks before hand.
ReplyDeletehttp://sarangasl.blogspot.com/2011/10/android-web-service-access-tutorial.html
DeletePlease try above post.
Thanks !
hi ,
ReplyDeleteI was imported your project but it is not giving any output
please tell me if you can see any errors in log.
DeleteVery helpful dude. Great Work!!!!!!!!!
ReplyDeleteThanks for commenting...
DeleteHi. I'm trying to access a webservice on my android app. The webservice is running in a Virtual Machine (and working, already made requests using Soap UI). I already developed my code, but i keep getting this error:
ReplyDeleteI get exception "org.xmlpull.v1.xmlpullparserexception expected start_tag"
i think it has to be with the SOAP_ACTION or NAMESPACE, but i already tried all the alternatives that i think that are right.
Any help on this one plz? Thank you!
Hi,
DeleteFirst try with (envelope.dotNet = true;)
e.g.
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
If it doesn't help, can you please send me the code that you are referring. My gmail id is saranga.rathnayake
Thanks !
It didn't work out.
ReplyDeleteHi Saranga,
ReplyDeleteIts really good post. I appreciate for posting this, because I am new to android. But I had the following error in console while run it. Could you sort this out please..
java.lang.NullPointerException
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.doSyncApp(AndroidLaunchController.java:923)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.syncApp(AndroidLaunchController.java:896)
at com.android.ide.eclipse.adt.internal.launch.AndroidLaunchController.clientChanged(AndroidLaunchController.java:1546)
my webservice has
ReplyDeleteattributeFormDefault="unqualified" elementFormDefault="unqualified"
can the problem be here?
hi,
ReplyDeletei gt some problem with my webservice, please tell me how to write data into database through web service(WSDL) in android br means of ksoap
Hello Saranga,
ReplyDeleteIts very useful tutorial but i am getting some error in logcat.so please suggest me.the error is under below
java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject..
Thanx in Advance.
Rename the "lib" folder to "libs" Then it should work fine. Like ant android ADT looking for libs resource folder.
Deletecan you please help me with the steps or sample code for writing webservice and publishing it.....
ReplyDeleteHi
ReplyDeletei need your help
i connect web service .net protocol (https)
i getting value "javax.net.ssl.SSLException:Not trusted server certificate"
Hi saranga, this is nag , please tell me how to retrieve the data from web server into our application?
ReplyDeleteHow to retrieve some feilds from websites?
thanks a lot dear...
ReplyDeleteur example helps me a lot but there is a problem when we call web service method with parameters, response returns null but without parameter method returns value. Kindly help me...
Dear sanchitsoftware,
Deletei have the same probleme, did you find the solution of this issue?
best regards
Hi Saranga, I am following ur tutorial but I am getting java.net.ConnectionException error.. ll u plz help me..
ReplyDeleteHi...
ReplyDeletePls tell me how to store data on web server using asp.net webservice in android...
hi,im trying to run this tutorial but the response is not displayed in android 4.0.3 or even 2.3.3,pliz help
ReplyDeleteHI Saranga
ReplyDeleteThank you veey very much
Great tutorial!
Thank you Sir
ReplyDeleteGreat tutorial!
Saranga Rathnayaka hi saranga i am new to android development could you tell me career in android as i am from the background of .net at the same time could you tell me my career at +2years
ReplyDeletehere we are consuming asmx service but i need to consume svc service
ReplyDeletecan you help me??
THIS TUTORIAL is great.I tried to use it for another service but it returns false...internet permissions are set.what could be the problem. this particular one runs
ReplyDeleteTHIS TUTORIAL is great.I tried to use it for another service but it returns false...internet permissions are set.what could be the problem. this particular one runs
ReplyDeletethank u very much every day i visit u r blog nice work thank u very muvh
ReplyDeletethank u so much gud tutorial i am every day seeing this very gud work helps me so much thanks thanks:):)
ReplyDeletewhat will be the password and username to enter successfully through next activity??
ReplyDeletewhen run the above code the emulator says application has stopped.
ReplyDeleteand i dont know how to solve this problem.. please advice as fast as possible
when i run the code the emulator says application has stopped.
ReplyDeletei dont know how to solve this problem
please advice as fast as possible coz i need to fix this problem
Hi Saranga,
ReplyDeleteThank you so much for this post.
With some other config, I can access my own web service(using SOAP and running on local host of PC) from my Android device with URL "http://ip-address/mywebservice".
However, if I create a RESTful web service, I can browser it with url "http://localhost/mywebservice" but cant browser with "http://ip-address/mywebservice". And, of course, I can't access this web service from my Android device.
Do you have any information to help me?
Hope to hear you soon.
Best regards,
Dzung
Hi Saranga,
ReplyDeleteThank you so much for this post.
With some other configs, I can access to my own SOAP web service (running on local host of PC) from my Android device with URL: http://ip-address/mywebservice.
However, if I create a RESTful webservice, I can browse it as http://localhost/mywebservice but can't browse with http://ip-address/mywebservice. And, of course, I can't access it from my Android device.
Do you have any information to help me?
I hope to hear you soon.
Thank you so much.
Dz
@Saranga Rathnayake
ReplyDeleteI am used your code in my eclipse,
but it did not showed any response on my emulator screen,
is that problem with my eclipse or what,
i have not installed WTP plugin,
does that cause this,
plz help.
i have tried to debug it but it also does not help,
and i got warning that said
"This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.".
Hello sir i am Rajan.
ReplyDeleteI am trying to fetch the data from the .asmx web service since last 1 or 2 days but i didn't get any proper output.
I have also try your example but i am getting the same exception, i didn't understand what is going on. so, sir please help me as soon as possible, here i am putting my logcat entry...
Logcat
------
W/System.err(880): org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT ? ? in java.io.InputStreamReader@44ef9a90)
08-06 15:06:46.741: W/System.err(880): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.error(KXmlParser.java:269)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.pushEntity(KXmlParser.java:787)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.pushText(KXmlParser.java:855)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.nextImpl(KXmlParser.java:354)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.next(KXmlParser.java:1385)
08-06 15:06:46.751: W/System.err(880): at org.kxml2.io.KXmlParser.nextTag(KXmlParser.java:1415)
08-06 15:06:46.751: W/System.err(880): at org.ksoap2.SoapEnvelope.parse(SoapEnvelope.java:127)
08-06 15:06:46.751: W/System.err(880): at org.ksoap2.transport.Transport.parseResponse(Transport.java:100)
08-06 15:06:46.751: W/System.err(880): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:214)
08-06 15:06:46.761: W/System.err(880): at org.ksoap2.transport.HttpTransportSE.call(HttpTransportSE.java:96)
08-06 15:06:46.761: W/System.err(880): at com.simform.androidsoapwebservicedemo.MainActivity.onCreate(MainActivity.java:58)
08-06 15:06:46.761: W/System.err(880): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-06 15:06:46.761: W/System.err(880): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
08-06 15:06:46.761: W/System.err(880): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
08-06 15:06:46.761: W/System.err(880): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
08-06 15:06:46.761: W/System.err(880): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
08-06 15:06:46.761: W/System.err(880): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 15:06:46.761: W/System.err(880): at android.os.Looper.loop(Looper.java:123)
08-06 15:06:46.761: W/System.err(880): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-06 15:06:46.761: W/System.err(880): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 15:06:46.761: W/System.err(880): at java.lang.reflect.Method.invoke(Method.java:521)
08-06 15:06:46.761: W/System.err(880): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-06 15:06:46.761: W/System.err(880): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-06 15:06:46.761: W/System.err(880): at dalvik.system.NativeStart.main(Native Method)
Hi saranga,
DeleteHi tried your code but I am getting a run time exception that application stopped unexpectedly.
can you please help me.
please find the logcat below.
08-10 08:18:50.696: E/AndroidRuntime(490): FATAL EXCEPTION: main
08-10 08:18:50.696: E/AndroidRuntime(490): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject
08-10 08:18:50.696: E/AndroidRuntime(490): at com.example.Web_Services.Web_ServicesActivity.onCreate(Web_ServicesActivity.java:28)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.os.Handler.dispatchMessage(Handler.java:99)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.os.Looper.loop(Looper.java:123)
08-10 08:18:50.696: E/AndroidRuntime(490): at android.app.ActivityThread.main(ActivityThread.java:3683)
08-10 08:18:50.696: E/AndroidRuntime(490): at java.lang.reflect.Method.invokeNative(Native Method)
08-10 08:18:50.696: E/AndroidRuntime(490): at java.lang.reflect.Method.invoke(Method.java:507)
08-10 08:18:50.696: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-10 08:18:50.696: E/AndroidRuntime(490): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-10 08:18:50.696: E/AndroidRuntime(490): at dalvik.system.NativeStart.main(Native Method)
Regards,
sandesh(sandeshk779@gmail.com)
finally i got the solution after following this blog
Deletehttp://lalit3686.blogspot.in/2012/06/calling-soap-webservice-using-httppost.html
Hi Saranga,
ReplyDeleteI have been trying to learn about calling web services from android and found your tutorial online.
I have imported it and getting the following error for each of the methods below:
weightProp.setName("Weight");
weightProp.setValue(weight);
weightProp.setType(double.class);
request.addProperty(weightProp);
"The method setName(String) is undefined for the type weightProp"
Is there something missing? Do I need to have an extra class, or how do I define these methods?
Could you please please help me??
Thank you soo much.
Assalamulaikum Saranga,
ReplyDeleteYou have helped me alot with this post. May Allah bless you.
This is very nice tutorial...thanks for posting this tutorial....how is update dropdown value from android to mysql database....please help me or post the tutorial for this.
ReplyDeleteNice Blog !
ReplyDeleteHowever, can you please also let us know how to access a WebService which requires Username/Password Authentication ?
It worked for me.
ReplyDeleteThanks a lot :)
Hi, i check above code in my eclipse.But i got response result value=0, so please help me how to get exact value
ReplyDeleteplease tell me why it is not run on android 2.2 onwards version
ReplyDeletewill i use json to access the web services in .net.if yes tell me the answer code.
Deletehow can i send two textbox data to my Mysql database i.e. localhost(wamp)
ReplyDeleteHello. I downloaded your code and tried it in both emulator and mobile but it force closes on both platforms. Perhaps you can help? I am trying to run your code in eclipse and android version 2.2 onwards.
ReplyDeleteThank you
Saurin
ReplyDeleteOne solution might be to rename the "lib" folder in the original uploaded project to "libs". It worked for me to get rid of the original crashings
Saranga, I have a question. I was able to make the application run, then I run the web service, I checked on the method in the .NET project, and is comparing user and pass with user=saranga, and pass=saranga. I type that on the Android app but get always "LOGIN FAILED" message. Any idea what could be causing this?
ReplyDeleteThanks
Miguel
Hai Saranga,
ReplyDeleteWhen i tried to execute code what u written it gives the blank screen and line
androidHttpTransport.call(SOAP_ACTION, envelope); doesn't reach, I am Using Android 4.0.
please help me
Hello Saranga
ReplyDeleteSame for me, please help
Thanks
Can any one help me...
ReplyDeleteI have tried Web service for 1st time and deployed it on local server its url is http://172.18.6.177:8080/TrialApp/Login?wsdl
and method name is authenticate
What will me NAMESPACE and SOAP_ACTION
hai Saranja
ReplyDeletei tried u r code but geting error in the log
the error (java.net.UnknownHostException: Host is unresolved: www.webservicex.net:80)
pls help me
one of the best example i have ever come across thanks dude!!perfectly working
ReplyDeletehi nice tutorial...
ReplyDeleteit really helpful for me.
hi nice tutorial
ReplyDeleteHello Saranga
ReplyDeleteyour post is very useful, but I have a small problem
I am new to Android platform.
My web service is accessible via a web application. Net.
but I can not get a response via Andriod.
When I call 'androidHttpTransport.call (Exec_SOAP_ACTION, envelope);'
execution proceeds directly into the 'catch'
have you an idea about the origin to the problem.
Thx ...
Hello Saranga,
ReplyDeleteyour post is very useful, but I have a small problem
I am new to Android platform.
My web service is accessible via a web application. Net.
but I can not get a response via Andriod.
When I call the 'androidHttpTransport.call (My_SOAP_ACTION, envelope);'
execution proceeds directly into the 'catch' and (Exception e) is null
have you any idea about the origin of the problem.
Thx ...
Bro, It's great, working fine,
ReplyDeleteBut it's not the one, which i exactly need,
I get the "false" loop when i enter the username and password in the fields off android... But i have the same fed already in the database!!It shows the echo the successful login, but.... if (str.toString().equalsIgnoreCase("true"))fails! Any idea???
Hello Dear ,
ReplyDeletei Make it as same u have done.
I ran it on AVD but no error and no result is showing..
In above example i have done same as u shown in example. but no result and no error is showing.
ReplyDeleteThis is very useful information.. thank you..
ReplyDeleteI need your help
I have my webservice running but i need to call it many times,it is taking the parameter only which i assigned for the first time,its not getting changed in propertyinfo
i need to call a webservice repeatedly in my android application
ReplyDeleteso how do i do this
Hi. I hope you can help me with this. The program stops when I reach the line with: SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
ReplyDeleteany idea? Thanks in advantage
Getting a error as follows: Please help me to resolve the same
ReplyDelete11-01 16:38:53.929: E/AndroidRuntime(18212): FATAL EXCEPTION: main.
11-01 16:38:53.929: E/AndroidRuntime(18212): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject.
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.sencide.AndroidWebService.onCreate(AndroidWebService.java:28).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.access$1500(ActivityThread.java:117).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.os.Handler.dispatchMessage(Handler.java:99).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.os.Looper.loop(Looper.java:130).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.main(ActivityThread.java:3687).
11-01 16:38:53.929: E/AndroidRuntime(18212): at java.lang.reflect.Method.invokeNative(Native Method).
11-01 16:38:53.929: E/AndroidRuntime(18212): at java.lang.reflect.Method.invoke(Method.java:507).
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867).
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625).
11-01 16:38:53.929: E/AndroidRuntime(18212): at dalvik.system.NativeStart.main(Native Method).
Please help me on the above error
ReplyDelete11-01 16:38:53.929: E/AndroidRuntime(18212): FATAL EXCEPTION: main.
11-01 16:38:53.929: E/AndroidRuntime(18212): java.lang.NoClassDefFoundError: org.ksoap2.serialization.SoapObject.
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.sencide.AndroidWebService.onCreate(AndroidWebService.java:28).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.access$1500(ActivityThread.java:117).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.os.Handler.dispatchMessage(Handler.java:99).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.os.Looper.loop(Looper.java:130).
11-01 16:38:53.929: E/AndroidRuntime(18212): at android.app.ActivityThread.main(ActivityThread.java:3687).
11-01 16:38:53.929: E/AndroidRuntime(18212): at java.lang.reflect.Method.invokeNative(Native Method).
11-01 16:38:53.929: E/AndroidRuntime(18212): at java.lang.reflect.Method.invoke(Method.java:507).
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867).
11-01 16:38:53.929: E/AndroidRuntime(18212): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625).
11-01 16:38:53.929: E/AndroidRuntime(18212): at dalvik.system.NativeStart.main(Native Method).
where is the main layout?
ReplyDeleteHi am using all these code but not any result comes on my layout scree it's a blank screen
ReplyDeleteHi All,
ReplyDeleteI am new to android programming, can you help on importing this jar file on android studio?
Thank you in advance.
Hello Brother I don't know about web services and parsing.
ReplyDeletecan u please share a simple program to understand both
hiii brother,
ReplyDeletethis code does not work in my project.
its does not call
androidHttpTransport.call(SOAP_ACTION, envelope);
and Null Pointer exception is generate.
Please help me....
Thank you
Can you please tell me the username & password? When i entered login, it will show as unfortunately AndroidLogin has stopped
ReplyDeletei am new to android when i tryed to login using your code but nothig happens i am using asp.net webservice i tryed to find the problem i felt it at
ReplyDeleteHttpResponse response = httpclient.execute(httppost);
will you help
code not working something wrong at
ReplyDeleteHttpResponse response = httpclient.execute(httppost);
will someone help
Hi
ReplyDeletePlz post page on consuming httpstransportse ksoap2 object connection for WCF services.
Thanks in advance
Any idea , i have problem duing passing object: http://stackoverflow.com/questions/23364562/passing-object-on-soap-and-getting-java-lang-runtimeexception-cannot-serialize
ReplyDeleteGuys I have a problem during passing object. http://stackoverflow.com/questions/23364562/passing-object-on-soap-and-getting-java-lang-runtimeexception-cannot-serialize
ReplyDeleteSoapPrimitive response = (SoapPrimitive)envelope.getResponse(); i have to read a particulor
ReplyDeletechild but your code is response is show all json type xml so i have to read a particular one Single child node plz reply fast
Good post , Have you any idea about How to implement same example what you have given above , over the ssl . please share it. Thanks
ReplyDeleteGood post. ..... Have you any idea about how to implement the same example what you have given , over the SSL ..... Please share it. Thanks .....
ReplyDeleteHappy coding ;)
Hi,Saranga Rathnayake
ReplyDeleteI have small requrement, I was dovelop a barcode scaner app.
it's work properly and it give barcode nuber.Now my requrement is ''WRITE A WEB SERVICE TO take that barcode number and DISPLAY THE PRODUCT DETAILS OF THT barcode number. I have probem with write a web service code,
please help me to compleate this application
Hi there, I hv tried running your code, but I got the error. When I debug, the error is from here.
ReplyDeleteandroidHttpTransport.call(SOAP_ACTION, envelope);
Error i am getting is:android.os.NetworkOnMainThreadException
can help on this? I gave internet permission in manifest file also.
Any help is very much appreciated. Thank you in advance
i face error here
ReplyDeleteimport org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;