开发者

What's the difference between cURL + HTTP and RESTful web services?

开发者 https://www.devze.com 2023-03-21 16:21 出处:网络
I don\'t understand the difference between a) on the server side initiating a cURL connection and transmit POST information to http://somesite.com/action and receiving XML data

I don't understand the difference between

a) on the server side initiating a cURL connection and transmit POST information to http://somesite.com/action and receiving XML data

and

b) using cURL to access RESTful web services

Are a) and b) the same thing? Are they synonym开发者_如何学Pythonous?


The only difference is whether the action invoked by the URL is a RESTful service. If the action depends on storing or retrieving state from a cookie or hidden field, then it isn't really RESTful. I don't know if this makes a difference to you, in your case it probably only determines the kind of error response you get back. RESTful services also have conventions regarding how they behave when they receive a GET or PUT instead of a POST, which may matter if you're trying to interact with a system instead of just interrogate it for some data.


I'm not sure I understand the significance of "on the server side", please elaborate if there is any. Otherwise:

Accessing a RESTful web service consists of accessing an URL via HTTP, so b, is really a subset of a.

When done right, the client usually needs to issue multiple GET request to "drill down" to the specific resource it intends to work with. Then it may cache the specific URL, but hard-coding it or constructing it on the client side is not considered elegant.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号