Representational state transfer and Simple Object Access Protocol (ANDROID) - android

Ok i am not sure if this question has been asked before on SO.. I am confused with SOAP and REST.. I know that SOAP is formatted in XML and is send over HTTP whereas REST can be send over XML, JSON etc.. Representational state transfer (REST) and Simple Object Access Protocol (SOAP) makes a pretty good point.
But does that mean that SOAP cannot be send using JSON????..
I am asking the above question in reference to android.
I know this is a pretty stupid question, but i am really confused on this one.
Any help is appreciated!!...
Thanks.

But does that mean that SOAP cannot be send using JSON?
Correct. Quoting Wikipedia:
SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on XML Information Set for its message format...
And note that this has nothing to do with Android.

Actually SOAP or Simple Object Access Protocol is an envelop format for exchanging WebService request and response information. REST is a special kind of WebService that must be designed with a set of constraints. For example in a RESTful WebService method information must be placed in the HTTP method and scoping information must be placed in the URI.
For understanding the architecture of web services and for a good introduction to RESTful web services i highly recommend you to read the following book:
http://www.amazon.com/Restful-Web-Services-Leonard-Richardson/dp/0596529260

Related

Android and Webservice

I am working on android project that connects to a database,
while I'm looking for tutorial I found ones that creates .php files and connect them with the android app using HttpClient and HttpPost,
and then exchange data with json.
this one is clear.
I found also other toturials that confuses me!
they are talking about using SOAP and wsdl files??
the links they were using for connecting to web service was with .wsdl extension!
Can someone explain to me what are they?
Thank you.
SOAP EN WSDL have something to do with xml, I dont recommend you to use xml either.
I recommend you to use json, because performance of json is better than xml.
I highly to recommend you to use volley https://developers.google.com/events/io/sessions/325304728
There are enough examples on the internet to make it work very well with your application!
However if you want to make a webservice see the question here > Android WSDL/SOAP service client
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate, however, the only bindings described in this document describe how to use WSDL in conjunction with SOAP 1.1, HTTP GET/POST, and MIME.
source:http://www.w3.org/TR/wsdl

Synchronizing android with the web

I was wondering if there are some commonly used techniques for synchronizing an app with a server? I have looked at the socket-framework and maybe some http? I am thinking for instance when making a game or a grocery list, any developers out there who want to share?
I would say that the most common method is to send client data via HTTP POST using SSL/TLS encryption. The data can be sent in any format, but generally it is structured as a JSON or XML message.
The hardest part is that you need some form of authentication in order to identify the user and update/sync the correct information on the server database in a secure manner. Have a look at this article for some basic concepts.
In android, you can use the excellent Google Gson library to convert Java object to/from JSON objects.
Http communication can be performed via the Android API methods.

Using REST to Send and Receive Complex Data

My client is an Android app and my service is an asp.net web api. I’m the only one using my service. I am trying to duplicate, in the Android-REST world what I am already doing in the Microsoft Windows Phone 7/ WCF SOAP world. I have numerous methods that both receive complex objects and return complex objects.
The WCF-SOAP world is simple. You can pass any complex arguments you want and return any complex results you want. Logically, it’s just a Remote Procedure Call.
But when I post questions about doing the same thing in REST, I’m told I should limit my services into GET, PUT, POST, and DELETE only. And that I should only do what is “proper” according to RFC2616. Some speak of this in almost a religious manner.
Forgeting about the religion, what’s wrong with using a GET for everything? Or what’s wrong with using a POST for everything? What I do does not fall into the simplistic RFC2616 categories. For instance I’m passing a thousand legs of a trip taken in a car and I’m getting back another version of that trip with erratic GPS errors smoothed out. Or, I’m sending a conversation in english and getting that conversation back in German.
In the android client I have the objects I want to send over HTTP already serialized into json strings by using Google-GSON. So my questions are…
How can I send these json strings to my REST Service as arguments in either GET or POST?
Is it possible and feasible to use just all GETs (or all POSTs) for all of my calls to my REST Service and how do I do that?
I have a more pragmatic question about this posted at sending a json string in a http url as I can’t find any examples anywhere of sending json strings over http GET or POST.
Thanks, Gary
Using the good HTTP verb is very usefull to simply know what to do when you request failed (for example) or just to do some specific stuff. If you sent a POST request, it's implicitly suppose that you have to parse your resource in order to obtain a stream which be sent via the request's body. In other hand, when you are retrieving data via GET, it's suppose that the request is gonna be sent back to you as a stream that you will mapped to your model, pojo, or anything else.
I can suggest you to use library such as RESTDroid. You can send POJO and receive POJO. It's a "resource oriented" library, so you can know at any moment if a particular local resource is remotely syncronized. Data persistence between local and remote is automatically handles.
RESTDroid is alpha released. You can have a look to RoboSpice. It's a powerful library to manage REST call but it's up to you to manage the persistency between local and remote resources.
1) The WCF-SOAP world is simple. You can pass any complex arguments you want and return any complex results you want. Logically, it’s just a Remote Procedure Call.
- IN REST:"You can pass any complex arguments you want and return any complex results you want too.
2a) Forgeting about the religion, what’s wrong with using a GET for everything?
In SOAP services WCF/or classical you are wrapping all requests into http POST so using single verb would end up to SOAP or - don't even think about it - your own communication protocol:-D
2b) You can technically compose GET request with non empty body - most of the servers ignore it by default though and it would be technically problematic to read it..
the other part of the question is answered by Pcriulan above

Should i use SOAP or REST in accessing Web service?

i want to access a java web service Running on a Server. which one SOAP or JSON is good to access this web service. i dont want to put overhead on the Server and want the calling of web service to be Fast. plz suggest better way to do this.
JSON and SOAP are two different things. JSON is just a data format while SOAP act as Manager on server side that manage request and response from client.. it can return JSON as a result which is a data format likehttp://stackoverflow.com/questions/9382864/answer/submit XML
You do not access a Web Service with JSON, that is just a format. Depending on the Web Service you might need to communicate with it by sending SOAP envelopes or using REST.
Ok, there is a lot of confusion here. SOAP/REST are two approaches to managing services ON THE SERVER SIDE. SOAP is XML-based, while REST is URL based. Assuming you are writing an Android app, you won't be implementing the SOAP/REST/WSDL interfaces-- you will get them from the service team.
So, if the web service you are using provides both REST and SOAP, then you can choose which set of endpoints to hit.
When you are packaging up your request and sending it to the service, you probably want to package it as JSON. JSON is just "Object Notation." Inherently, it is nothing more than a way to format data in such a way it universally recognized. Alternatively, you can package your request as XML. But JSON is more light-weight, as XML has a lot of required redundancy (unless it is compressed).

Android web app

What are the best ways to connect site and show it's data on an android application ? Also does I have to create anything on server where the site is for using JSON ? I am new to programming web android application's, though I searched a lot I didn't find anything which would explain me straight to the point.
You're on the solid ground starting out using JSON as the interchange between the two.
Alot of popular mobile apps like Twitter and Foursquare have restful APIs set up to interact with their mobile clients by exchanging HTTP requests that contain data formatted as JSON. Most of the communication between the two can be accomplished with HTTP requests using the standard GET and POST methods.
A good place to start would be setting up some server endpoints that output this data and then setting up your android app to request and parse this data just like a browser would. You just need to set the appropriate mimetypes on your server end (application/json).
Most modern server-side languages have implemented modules/functions that can take their native data structures and approximate them in serialized JSON (PHP's json_encode(), python's json.dumps() etc) These can be used to output data from within the app or database to your mobile client where it can be interpreted and used in the Java environment there.
To pass back JSON you need to set the mime type (http://stackoverflow.com/questions/477816/the-right-json-content-type), which is application/json.
If you are passing back JSON or XML then the client just needs to make the appropriate http call, most likely GET, perhaps POST, to actually retrieve the information.
You can use something like this as a starting point:
http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

Categories

Resources