Are all web services automagically restful web services?

后端 未结 6 1346
抹茶落季
抹茶落季 2021-01-15 12:19

Are all web services through HTTP and not SOAP automagically restful web services?

I have been hearing the term \"Restful web services\" everywhere.. but ain\'t it s

相关标签:
6条回答
  • 2021-01-15 12:41

    One of the cornerstones of "REST" architectural style is using HTTP to its full potential (GET, HEAD, PUT, POST, DELETE, content-type, etags, cache control, etc) instead of as a tunnel. If you do just that, you already win a lot, and I think you should feel entitled to call your service "REST Inspired" or something. From there you can use all the existing building blocks of HTTP infrastructure to your advantage, instead of having to work against them.

    It's often tempting to come up with your own RPC or CRUD protocol over HTTP, and reinvent the wheel. The result is usually quite contrary to REST principles.

    0 讨论(0)
  • 2021-01-15 12:49

    The acronym REST stands for Representational State Transfer, this basically means that each unique URL is a representation of some object. Other (such as SOAP) are more RPC-like. SOAP refers to Simple Object Access Protocol and is usually overlaid onto the HTTP POST. SOAP has recently been stretched in some REST-like directions.

    0 讨论(0)
  • 2021-01-15 12:51

    Are all web services automagically restful web services?

    No there is no magic. You have SOAP and other protocols which are not RESTful.

    0 讨论(0)
  • 2021-01-15 12:53

    There are at least two types of web services around:

    • SOAP web services - using XML Schema to strictly define XML messages, typically, but not necessarily using HTTP as a transport protocol. Reliable and standardized, they've been around for quite some time, although sometimes considered heavyweight.

    • RESTful web services - less rigid, using plain HTTP protocol, taking advantage of built-in GET/POST/PUT/DELETE methods to perform CRUD operation on resources. Content negotiation (typically XML or JSON), redirects (Location header) and user-friendly URLs make RESTful web serives getting more attention.

    These are two different communication protocols, you can migrate one into another, but no automatic conversion ever happens.

    0 讨论(0)
  • 2021-01-15 12:57

    No, because to be a REST service, it needs to fulfil certain criteria. See wikipedia

    There is a quote there which might answer your question better than I can:

    SOAP RPC contrast

    SOAP RPC over HTTP, on the other hand, encourages each application designer to define a new and arbitrary vocabulary of nouns and verbs (for example getUsers(), savePurchaseOrder(...)), usually overlaid onto the HTTP POST verb. This disregards many of HTTP's existing capabilities such as authentication, caching and content type negotiation, and may leave the application designer re-inventing many of these features within the new vocabulary.[8] Examples of doing so may include the addition of methods such as getNewUsersSince(Date date), savePurchaseOrder(string customerLogon, string password, ...).

    0 讨论(0)
  • 2021-01-15 12:59

    If all your request go through the same URI then this is a clear sign that you're not using URIs to identify the individual resources of your system, so - no.

    That being said; there are more constraints such as uniform interfaces, or hypermedia-driven.

    0 讨论(0)
提交回复
热议问题