I want to learn how to consume web services in android , and i have done some research on it , i have seen that .net web services are in XML format and return response in XML, when PHP web services are give jason array in response , i have used ksoap for .net web services , is ksoap can also used for php web services?
I think you misunderstood. .Net is not only to generate data in XML format.It is also possible to generate JSON data using .NET also and it is also possible to generate XML format using php.Most of the people will use JSON only because it is light weight and its easy parse from client side.Parsing XML data is really pain in my opinion.
And you asked ksoap also used for php?Yes it is.
See the below link
http://www.petetracey.com/2009/11/ksoap-with-php-tutorial/
Above site is my site so thought I'd clear this up a bit -- SOAP is a protocol that uses XML as its underlying format. It's one of many options that use XML. KSOAP (with the K) is the Java library, for blackberry but may be somewhere in the android libs or tacked on somehow. Still I think the better option is JSON, it is lighter weight and parses faster and therefore for mobile with data rates/limited processing power/battery consumption goes up with processor use -- you want to be lean and mean.
So any modern language, be it PHP, .NET, whathaveyou++, has libraries for both JSON and XML - and most have SOAP either built-in or as the 3rd party library somewhere. Which to use is the right tool for the job, and SOAP at this point is pretty much a legacy technology outside of the Sun/Oracle and Microsoft world.
Related
Currently I am working on an iPhone app. But the company also would like to have an android version for this app.
I have programmed all the request by Soap and used for the iPhone the Soap Request Generator of Sudz-C.
I am wondering now if something similar exists for the Android, It would be nice if I don't have to program this all by myself.
Anyone have some experiences or ideas?
You can use
http://easywsdl.com
website to generate all required java classes for your webservice. It uses ksoap2 library and supports many features like objects sent as references (WCF IsReference), complex inheritance, document and rpc style of webservice, all standard data types (including normal enums and IsFlag enums), and much more
ksoap2-android is what you are looking for, it will send/recive soap request's, is easy to use and on MIT license
I go through a lot of solution solution in WSDL 2 android. google don't matter about SOAP service and provide anything for it. wsdl2java won't work in most of case, some library cannot be use by android SDK. I suggest you to use http://easywsdl.com.
you'll see you can edit your own package name, class prefix and many other parameters depends on your need. If you have complex data and your are familiar to use Gson (https://code.google.com/p/google-gson/) to send parameter between your activities don't check "Use JodaDate" that is a great library for using date, but Gson doesn't support it (yet).
If you have few services that don't work (yes that can happen, depend of your WSDL configuration file), report it to contact and they will make the possible to fix your issue like they did for me.
The generator is fast. you will receive all your generated code and the .jar that you'll have to import into your project.
In web-service fundamental, I have heard about "SOAP" and "KSOAP."
What are SOAP and KSOAP?
What is the difference between them?
Why should I use one instead of the other one?
SOAP - SOAP is an XML vocabulary used to describe messaging and
remote procedure calls between distributed components.Any modern
language that works with the Internet is likely to support both XML
and HTTP.
KSOAP - KSOAP is a SOAP API based on kXML,where kXML is a
lightweight Java-based XML parser designed to run on limited, embedded
systems such as personal mobile devices. It is a pull parser which
means it reads a little bit of the document at once
So, KSOAP was specially was designed or developed to deal with small embedded device like mobile devices.
SOAP - Most enterprise-level SOAP toolkits often rely on the use of a Web Services Description Language (WSDL) generated proxy object to make function calls. This is useful if a service has a published description and when the toolkit requires the instantiation of several different client and transport objects.
KSOAP - While kSOAP doesn't support WSDL, it does make calling a service relatively painless. Only two objects are required: the SOAPObject and Http-Transport.
CONCLUSION - SOAP can be a very complex realm to explore, especially the XML mechanisms used to transfer data between disparate systems, languages, and toolkits. The wireless world requires tools of small stature and great power. Luckily when it comes to SOAP, the kSOAP toolkit provides not only small size and great functionality, but also relative simplicity and ease of use for the developer. Using kSOAP, a developer can develop complex SOAP Web services clients in a remarkably short time.
KSOAP is a "lightweight and efficient SOAP library for the Android platform."
SOAP is a protocol used for building web services, and which defines a format used for the exchange of messages that uses XML as base.
You cannot use one instead of the other, as they are two different things: The first is the library necessary to use a protocol, and the second is the protocol used from the first.
I want to build a server that communicates with an android phone
based on a request/response model
At first i thought i will use Httpservlets and communicate with the android
by Http messages. but i need to be able to access a pretty big object with every
request so i guess i cant really transfer the object to the servlet.
so i know this is a pretty newbish question but iv'e been searching for days
what kind of java EE tech should i use(i thought of EJB but as i understand they cant communicate with android)?
Thanks in advance
I think the right question is how to implement service layer for your android application:
Basically there are two options REST based web services and SOAP. Android's support for SOAP is inadequate and I personally prefer REST over soap any day. If you have decided to go with REST, your options in Java are Jersey, RESTlets or Spring Rest services. I will prefer Jersey, but you can also look in to Spring ( although not strictly complaint with the JSR).
(note: look in "SO" for comparison on various rest based frameworks in Java)
I'm not asking to be spoon fed here, just need some pointers on where to direct my searching
I want to call a SOAP web service, possibly this one
I don't want to use KSoap, is there anyway I can do this using the apache libraries that are included with the Android SDK?
I want to call a SOAP web service, possibly this one
That does not look like a SOAP Web service. Try clicking that link in a browser, and you will see it is a plain XML document.
is there anyway I can do this using the apache libraries that are included with the Android SDK?
Yes. For true SOAP, plan to spend a substantial amount of time writing your own SOAP layer atop HttpClient. However, for consuming a simple XML document like the one you link to above, it should be fairly simple.
I think the XML is not WebService, it is simple XML... To call WebService with SOAP you can use kSOAP2 on Android platform, but I've created an another - proof-of-concept - SOAP client:
http://wiki.javaforum.hu/display/ANDROIDSOAP/Home
I'm a student trying to dive into the world of "complex web-enabled applications" for Android.
I had good tries making Android applications that call php functions, have JSON or XML responses and results, serialize objects and so on...
It really can work for simple projects, IMHO. For projects that require an increased complexity and control, I really would like to try something else.
Since Android apps are made in Java, I'm thinking it could be great if I could work with Java objects in Android and storing/retrieving Java objects in the server side too. Java Server Pages could be an answer, since I can embed Java code into HTML pages/HTTP services.
Is possible (and comfortable) to achieve this? Can I work with "local objects" in my Android app and with "remote objects" in my JSP app storing them, for example, in a remote database?
What could be an alternative?
I hope I've been clear. Thank you!
Spring android as HTTP client and ORMlite in the client side has been my salvation in many android projects. What I generally do is have this in the client side and in the server side use a Spring MVC server. But if your server is written in Php there's no problem. With this environment I can work with object in the client side and in the server side, never touching json/xml. I'm making a tumblr client in android. In this package I've all the things related to the Http client rest package. Look how I use it in this class example.