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

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.

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.

Can anyone tell the difference between SOAP and 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.

Are both REST and SOAP an implementation of SOA?

I have a question around SOA.
Are SOAP and REST both considered approaches for implementing a service-oriented architecture?
I know that REST is a style, thus this leads me to this question.
Yes, they both can be considered approaches for implementing a SOA. I suppose you could say REST is a style, but then you'd have to say SOAP is one too. I would simply consider them different techniques to accomplish the same end. SOAP mimics a Remote Procedure Call and REST is inline with how the web (http) was designed.
When creating/adapting services to work in a SOA architecture the interfaces exposed can be whatever you desire as long as the consumers have the ability to process the response.
For the sake of giving a more concise answer, I will interpret REST as being a HTTP interface which can perform the CRUD operations, perhaps responding to requests with an XML or JSON object.
SOAP tends to lend itself to more complex operations on the service side, the libraries and involved XML's of SOAP introduces complexity to the system.
If all you require is the representation of resources which can be accessed through simple CRUD operations it is worth considering implementing a REST interface to reduce complexity, even if the service will run along side services with SOAP interfaces. All that would be required is the consumer of the service is able to deal with the RESTful style responses as well as acting as a SOAP client.
There would be arguments for consistency across the service to improve maintainability and ease of development, but this isn't a necessity and should only be included in the decision process.
When including a messaging bus into the design, heterogeneous services can be dealt with even more effectively by inserting standard transforms (XSLT, custom) into the process which can translate the response from services into a standard format understood by the system as a whole.
If you simply ask whether both of them can be implemented using Service Oriented Architecture - yes they do. They can even be used both at once in a single SOA-based project.
If you are asking whether SOAP or REST should be used - there is no answer unless you provided project specifications.
SOAP and REST are ways of building services.
SOAP is XML based and, in theory, supports more than just HTTP, and has standards for interface definition (WSDL), and things like security (WS_Security).
REST is a style for doing web services in a resource-oriented manner using a defined set of web operations (GET, POST, etc), but defines very little else.
However, SOA is about much more than just a bunch of services. Choosing REST or SOAP is the easy part.

RESTful Services - WSDL Equivalent

I have been reading about REST and SOAP, and understand why implementing REST can be beneficial over using a SOAP protocol. However, I still don't understand why there isn't the "WSDL" equivalent in the REST world. I have seen posts saying there is "no need" for the WSDL or that it would be redundant In the REST world, but I don't understand why. Isn't it always useful to programmatically bind to a definition and create proxy classes instead of manually coding? I don't mean to get into a philosophical debate, just looking for the reason there is no WSDL in REST, or why it is not needed. Thanks.
The Web Application Description Language (WADL) is basically the equivalent to WSDL for RESTful services but there's been an ongoing controversy whether something like this is needed at all.
Joe Gregorio has written a nice article about that topic which is worth a read.
WSDL describes service endpoints. REST clients should not be coupled to server endpoints (i.e. should not be aware of in URLs in advance). REST clients are coupled on the media-types that are transfered between the client and server.
It may make sense to auto generate classes on the client to wrap around the returned media-types. However, as soon as you start to create proxy classes around the service interactions you start to obscure the HTTP interactions and risk degenerating back towards a RPC model.
RSDL aims to turn rest like a hypermedia, in other words, it has more information than a service descriptor like WSDL or WADL. For example, it has the information about navigation, like hypertext and hyperlinks.
For example, given a current resource, you have a set os links to another resources related.
However, i didn't find Rest Clients that supports this format or Rest Server Solutions with a feature to auto generate it.
I think there is a long way for a conclusion about it. See the HTML long story and W3C vs Browsers lol.
For more details about Rest like Hypermedia look it: http://en.wikipedia.org/wiki/HATEOAS
Note : Roy Fielding has been criticizing these tendencies in Rest Apis without the hypermidia approach: http://roy.gbiv.com/untangled/2008/rest-apis-must-be-hypertext-driven
My Conclusion : Now a Days, WADL is more common that Rest and Integration Frameworks like Camel CXF already supports WADL ( generate and consume ), because it is similar to WSDL, therefore most easy to understand in this migration process ( SOAP to REST ).
Let's see the next chapters ;)
Isn't it always useful to programmatically bind to a definition and
create proxy classes instead of manually coding?
Agree wholeheartedly, this is why I use Swagger.io
Swagger is a powerful open source framework backed by a large
ecosystem of tools that helps you design, build, document, and consume
your RESTful APIs.
So basically I use Swagger to describe my models, endpoints, etc, and then I use other tools like swagger-codegen to generate the proxy classes instead of manually coding it.
See also: RAML
There is an RSDL (restful service description language) which is equivalent to WSDL. The URL below describes its practice http://en.wikipedia.org/wiki/HATEOAS and http://en.wikipedia.org/wiki/RSDL.
The problem is that we have lots of tool to generate code from wsdl to java, or reverse.
But I didn't find any tool to generate code from RSDL.
WSDL is extensible to allow description of endpoints and their messages regardless of what message formats or network protocols are used to communicate
However, REST uses the network protocol by using HTTP verbs and the URI to represent an objects state.
WSDLs tell you at this place, if you send this message, you'll perform this action and get this format back as a result.
In REST, if I wanted to create a new profile I would use the verb POST with a JSON body or http server variables describing my profile to the URL /profile
POST should return a server-side generated ID, using the status code 201 CREATED and the header Location: *new_profile_id* (for example 12345)
I can then perform updates changing the state of /profile/12345 using the HTTP verb POST, say to change my email addresss or phone number. Obviously changing the state of the remote object.
GET would return the current status of the /profile/12345
PUT is usually used for client-side generated ID
DELETE, obvious
HEAD, gets the status without returning the body.
With REST it should be self-documenting through a well designed API and thus easier to use.
This is a great article on REST. It really help me understand it too.
WSDL 2.0 specification has added support for REST web services too. Best of both worlds scenario. Problem is WSDL 2.0 is not widely supported by most tools out there yet. WSDL 2.0 is W3C recommended, WSDL1.1 is not W3C recommended but widely supported by tools and developers.
Ref:
http://www.ibm.com/developerworks/library/ws-restwsdl/
The Web Application Description Language (WADL) is an XML vocabulary used to describe RESTful web services.
As with WSDL, a generic client can load a WADL file and be immediately equipped to access the full functionality of the corresponding web service.
Since RESTful services have simpler interfaces, WADL is not nearly as necessary to these services as WSDL is to RPC-style SOAP services.