Are all web services automagically restful web ser

2019-02-19 20:05发布

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 simply a plain old "web service that uses http".

I have a url at A.php and clients request data from me like this: A.php?parameters_supplied_here_etc_etc

And since the url has a length limit, for longer messages they will send a POST request with the parameters to A.php

Basically if anyone wants to talk to my server/database, it goes through the page at A.php

So can I say that it's a restful web service??

6条回答
走好不送
2楼-- · 2019-02-19 20:49

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.

查看更多
Explosion°爆炸
3楼-- · 2019-02-19 20:49

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.

查看更多
放我归山
4楼-- · 2019-02-19 20:56

Are all web services automagically restful web services?

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

查看更多
闹够了就滚
5楼-- · 2019-02-19 20: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, ...).

查看更多
别忘想泡老子
6楼-- · 2019-02-19 20:58

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.

查看更多
甜甜的少女心
7楼-- · 2019-02-19 21:02

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.

查看更多
登录 后发表回答