Can anyone tell the difference between SOAP and REST? - rest

I have the web service URL, login and password, but I can't understand is this SOAP or REST service.
I understand that SOAP is a protocol and REST is just an architecture, but I can't understand the difference between their mechanisms.
Thank you.

SOAP is a set of W3C specifications for web services protocols. In simple terms, those protocols define an XML "wrapper" for providing and consuming web services.
REST is a different kind of concept (as you noted); Wikipedia defines it as an "architecture for distributed systems"; to web developers it's a convenient way of configuring URI schemes to retrieve and update resources. HTTP GET to server/customers/1 gets you info about customer 1, and HTTP PUT to the same URI updates that customer.
In colloquial terms REST is sort of a lightweight alternative to SOAP. Maybe you don't need all the headers, security, and schema that SOAP provides; or maybe you're working in a bandwidth-sensitive area (like mobile web), where you don't want all that overhead. REST is kind of the shorthand way of referring to that alternate paradigm, and tends to get lumped together with other techniques like JSON and AJAX, even though they aren't technically related.

SOAP VS REST
SOAP is a protocol.
REST is an architectural style.
SOAP stands for Simple Object Access Protocol.
REST stands for REpresentational State Transfer.
SOAP can't use REST because it is a protocol.
REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
SOAP uses services interfaces to expose the business logic.
REST uses URI to expose business logic.
SOAP defines standards to be strictly followed.
REST does not define too much standards like SOAP.
SOAP defines its own security.
RESTful web services inherits security measures from the underlying transport.
SOAP permits XML data format only.
REST permits different data format such as Plain text, HTML, XML, JSON etc.

Related

Is SOAP a stateful protocol? Is REST really stateless? How can one store data using REST?

Is SOAP designed to be a stateful? How can it be reached? SOAP use RPC, so where to store data?
Is REST designed to be a stateless? Is it possible to store data in JSON ? Is it so wrong?
Thanks
Is REST designed to be a stateless?
Yes, it really is -- but Fielding is precise about what stateless means in the context of REST:
communication must be stateless in nature, as in the client-stateless-server (CSS) style of Section 3.4.3 (Figure 5-3), such that each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server. Session state is therefore kept entirely on the client.
In other words, to correctly interpret a request, the server does not need to remember any previous requests.
For example, contrast HTTP (where credentials are part of the metadata of the request) with FTP (where credentials are sent separately from the RETR command).
Comparing SOAP with REST is not so suitable, because SOAP is a protocol based on XML and REST is an architectural style that is by definition not bringged to a specific technology.
In any case the common use of REST is via http, like SOAP, and the common usage of REST with json and http is only a comfortable implementation that is very suitable for web development and machine to machine communication due to the incredible good support for json in almost all the modern programming language.
Said that SOAP is definitely stateless!.
When we fire a web service call with soap we create a SOAP envelop in xml and send it on a http channel, that is stateless by default.
During the years near to SOAP many other protocols that can be used with SOAP can add some feature to the protocol the well known WS-*. BPEL deserves some discussion, it is the most important standard for SOAP orchestration.
Even if with BPEL in my experience the engine provide a SOAP web service in order to create a "state full" web service, the fact that a BPEL process is exposed via SOAP it is not correlated with SOAP. BPEL is BPEL and SOAP is SOAP are two separated things.
said that yes REST is an architectural style that is stateless by design and it is particular suitable and used with http, but even soap is a stateless protocol that use http like transportation layer.
for the storing data part of the question, storing data is a application concern. Of course you can pass data in a rest api like a SOAP web service. For the SOAP web service usually you will post data on the body of the SOAP envelop. In a REST service typically you are creating/updating a resource and for this reason using the classical http implementation of REST you will perform a POST(create)/PUT(update all the resource)/
PATCH(update only a piece of resource) pasing the data in the body of the http request. of course do not forget the Content-Type http header on application/json.
I hope that it can help you

Why Google uses a lot of SOAP in spite of the following advantages in REST?

Why Google uses a lot of SOAP in spite of the following advantages in REST.
REST is an architectural style.
REST stands for REpresentational State Transfer.
REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
REST uses URI to expose business logic. REST uses (generally) URI and methods like (GET, PUT, POST, DELETE) to expose resources. JAX-RS is the java API for RESTful web services.
REST does not define too much standards like SOAP.
REST requires less bandwidth and resource than SOAP.
RESTful web services inherits security measures from the underlying transport.
REST permits different data format such as Plain text, HTML, XML, JSON etc.
REST more preferred than SOAP.
REST is an architectural style, unlike SOAP which is a standardized protocol.
REST follows stateless model
REST has better performance and scalability. REST reads can be cached. JSON usually is a better fit for data and parses much faster
No accepted standard for a JSON schema.
SOAP
SOAP is a protocol.
SOAP stands for Simple Object Access Protocol.
SOAP can't use REST because it is a protocol.
SOAP uses services interfaces to expose the business logic. JAX-WS is the java API for SOAP web services.
SOAP defines standards to be strictly followed.
SOAP requires more bandwidth and resource than REST.
SOAP defines its own security.
SOAP permits XML data format only.
SOAP is less preferred than REST.
SOAP is actually agnostic of the underlying transport protocol and can be sent over almost any protocol such as HTTP, SMTP, TCP, or JMS.
SOAP has a standard specification
SOAP has specifications for stateful implementation as well.
SOAP based reads cannot be cached.
The marshalling costs are higher but one of the core advantages of XML is interoperatibility. For XML, a schema allow message formats to be well-defined. Data typing and control is also much richer under XML.
Thanks in advance.
Steve Francia has a great comparison article on the subject, though I was under the impression (and Steve mentions) that Google had moved away from SOAP to REST. I would be curious if you are asking about a specific API? Then maybe I could formulate a more specific answer regarding that API.
However, overall, while REST is superior in almost every way, here is why you would use SOAP:
Web Service Security - SOAP supports WS-Security in addition to SSL, which adds some enterprise security features and identity through intermediaries, not just point to point (SSL). It also provides a standard implementation of data integrity and data privacy.
Web Service Atomic Transaction - WS-AtomicTransactions are necessary if you need Transactions that are ACID compliant (though probably not why Google would have been using it).
Web Service Reliable Messaging - SOAP has standard messaging through WS-ReliableMessaging, enabling built in successful/retry logic and provides end-to-end reliability even through SOAP intermediaries.

In soap there is WSDL for communication but in rest what is there ?

In SOAP there is WSDL for communication. I read in blogs that WSDL 2.0 supports REST but it is not properly define the REST so is there any equivalent for REST ? I'm doing communication using JSON data between client and server so i need something that properly fit for communication so is there is something for this ?
There are different proposals in the industry, such as WADL (see http://en.wikipedia.org/wiki/Web_Application_Description_Language ), but unfortunately there is no commonly accepted REST metadata standard yet.
In real WSDL can be used for REST but in reality it is not best fit for REST.
I would rather stay away from using WADL or any other descriptive languages, when it comes to REST style. RESTful services are fundamentally well-defined and self-descriptive in nature, hence the name Representational State Transfer. Given that they adhere to the HTTP vocabulary (CRUD) and payload structure can be any character-set (raw, JSON, XML. etc.), there is no need for any standard descriptive language.
This is the fundamental shift from SOAP based services, where application developers need to worry about describing the service interfaces in WSDL for discovery and other purposes.

What is the different between RESTful and RESTless

What is basic difference between restful and restless, i've been reading a few articles people seem to use them interchangeably.
REST stands for REpresentational State Transfer and goes a little something like this:
We have a bunch of uniquely addressable 'entities' that we want made available via a web application. Those entities each have some identifier and can be accessed in various formats. REST defines a bunch of stuff about what GET, POST, etc mean for these purposes.
the basic idea with REST is that you can attach a bunch of 'renderers' to different entities so that they can be available in different formats easily using the same HTTP verbs and url formats.
For more clarification on what RESTful means and how it is used google rails. Rails is a RESTful framework so there's loads of good information available in its docs and associated blog posts. Worth a read even if you arent keen to use the framework. For example: http://www.sitepoint.com/restful-rails-part-i/
RESTless means not restful. If you have a web app that does not adhere to RESTful principles then it is not RESTful
'RESTless' is a term not often used.
You can define 'RESTless' as any system that is not RESTful. For that it is enough to not have one characteristic that is required for a RESTful system.
Most systems are RESTless by this definition because they don't implement HATEOAS.
Any model which don't identify resource and the action associated with is restless. restless is not any term but a slang term to represent all other services that doesn't abide with the above definition. In restful model resource is identified by URL (NOUN) and the actions(VERBS) by the predefined methods in HTTP protocols i.e. GET, POST, PUT, DELETE etc.
Here are roughly summarized the key differences between RESTful and RESTless web services (it does not have to be strictly valid):
1. Protocol
RESTful services use REST architectural style,
RESTless services use SOAP protocol.
2. Business logic / Functionality
RESTful services use URL to expose business logic,
RESTless services use the service interface to expose business logic.
3. Security
RESTful inherits security from the underlying transport protocols,
RESTless defines its own security layer, thus it is considered as more secure.
4. Data format
RESTful supports various data formats such as HTML, JSON, text, etc,
RESTless supports XML format.
5. Flexibility
RESTful is easier and flexible,
RESTless is not as easy and flexible.
6. Bandwidth
RESTful services consume less bandwidth and resource,
RESTless services consume more bandwidth and resources.

Restful vs Other Web Services

What does it make Restful webservices different from the other Web Services like SOAP?
The debate over web services is by no means complete, but there are some elements that stand out.
RESTful web services are a 'family' of web services. Some would call it an architecture.
RESTful web services use the HTTP protocol to perform requests from a web service. They use the HTTP verbs: GET, POST, PUT and DELETE (and others, sometimes). The requests themselves are to URLs which represent resources... sometimes the requests will contain data in the body that could by HTML, JSON, binary data or other.
A purely RESTful web service only requires the URL and the HTTP verb to describe the requested action... the body data is usually a payload to be involved in the requested action... it should not dictate the requested action
SOAP, on the other hand, is actually a protocol. It is usually transported over HTTP, but the HTTP request is just a method to get the SOAP packet to the necessary handler. The contents of the SOAP request describes what the client wants performed. It contains all the necessary information.
They are two very different ways of implementing Web Services. If you ask the question "Which is better" you'll probably get strong opinions from both sides. I suggest you investigate further and make up your own mind.
A RESTful web service (also called a RESTful web API) is a simple web service implemented using HTTP and the principles of REST. Such a web service can be thought about as a collection of resources. The definition of such a web service can be thought of as comprising three aspects:
The base URI for the web service, such as http://example.com/resources/
The MIME type of the data supported by the web service. This is often JSON, XML or YAML but can be any other valid MIME type.
The set of operations supported by the web service using HTTP methods (e.g., POST, GET, PUT or DELETE).
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 eXtensible Markup Language (XML) as its message format, and usually relies on other Application Layer protocols (most notably Remote Procedure Call (RPC) and HTTP) for message negotiation and transmission. This XML based protocol consists of three parts:
an envelope - which defines what is in the message and how to process it -
a set of encoding rules for expressing instances of application-defined datatypes,
and a convention for representing procedure calls and responses.
references:
http://en.wikipedia.org/wiki/Representational_State_Transfer#RESTful_web_services
http://en.wikipedia.org/wiki/SOAP
By the way, a simple google search could provide answers for you...
Ok there is a wealth of knowledge in Stack Overflow on this topic.
I think the best article that articulates the spirit of REST and how it compares against technologies like SOAP is How I explained REST to my wife.
Unlike SOAP, REST is not a standard it's more of an approach that's centred around Resources and things you can do to resources. The HTTP verbs GET, POST, PUT and DELETE are typical actions that you can apply against any resource. SOAP is a standard that ignores these verbs and has invented a more comprehensive protocol that works on top of the most popular verb HTTP POST for maximum interoperability. Most of the time this added complexity is unnecessary and a simple HTTP GET request for a resource would normally suffice over what could be potentially 1KB+ of SOAP+XML to achieve an equivalent result.
You can also check out Roy Fielding's blog (the inventor of REST) for more information about what it means.
RESTful services focus on speed and simplicity, eliminating the overhead of SOAP for the simple transactions that many web services require. However, a service implemented in this way is very HTTP-specific, and you'll have a hard time making use of it outside of that context.
SOAP services offer more out-of-the-box features, the most important (imho, of course) of which is discovery. The ability to add a reference to a SOAP service in just about any dev environment and have it automatically generate a proxy class that will hide the underlying HTTP complexities, even to the point of serializing non-trivial types, is very, very useful.
I feel that both of these approaches to web service development have their place. For AJAX requirements that don't require anything complex, I tend to implement as an HTTP handler (ASP.NET). Anything that needs to be called from another application, or from multiple places within the same app, I implement as a SOAP service because of the protocol encapsulation that it provides, as well as the ability to call the use the underlying object without the HTTP overhead where it makes sense.
1) REST is more simple and easy to use than SOAP
2) REST uses HTTP protocol for producing or consuming web services while SOAP uses XML.
3) REST is lightweight as compared to SOAP and preferred choice in mobile devices and PDA's.
4) REST supports different format like text, JSON and XML while SOAP only support XML.
5) REST web services call can be cached to improve performance.