{"id":3782,"date":"2011-12-13T11:15:06","date_gmt":"2011-12-13T16:15:06","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=3782"},"modified":"2011-12-15T11:23:35","modified_gmt":"2011-12-15T16:23:35","slug":"restful-web-services","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=3782","title":{"rendered":"RESTful Web Services"},"content":{"rendered":"<span id=\"Intro\"><h2>Intro<\/h2><\/span>\n<p>Representational state transfer (REST) is a style of software design architecture.<\/p>\n<span id=\"RESTful_Constraints\"><h2>RESTful Constraints<\/h2><\/span>\n<p>In order to be RESTful, the architecture must comply to the following contraints.<\/p>\n<ol>\n<li><strong>Client-server<\/strong>:\n<ul>\n<li>Separation of concerns into client and server (loose coupling):\n<ul>\n<li>Client focuses on UI<\/li>\n<li>Server not concerned about UI<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>Stateless<\/strong>:\n<ul>\n<li>No client context is stored on the server between requests.<\/li>\n<li>All session state is stored in client.<\/li>\n<li>Server can be stateful, but every server side state need to be addressable by URL as a resource.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Cacheable:<\/strong>\n<ul>\n<li>All responses must indicate to client if they are cacheable.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Layered system:<\/strong>\n<ul>\n<li>Client does not know about the end server (Allow intermediary servers)<\/li>\n<\/ul>\n<\/li>\n<li><strong>Code on demand<\/strong> (optional):\n<ul>\n<li>Servers can temporarily extend or customize the functionality of a client by transferring logic (e.g. JavaScript) to the client.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Uniform interface<\/strong>\n<ul>\n<li>Uniform interface decouples client and server to achieve separation of concerns.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<span id=\"RESTful_Web_Services\"><h2>RESTful Web Services<\/h2><\/span>\n<p>RESTful web servies implement web services:<\/p>\n<ul>\n<li>Using HTTP <\/li>\n<li>Compliant with RESTful constraints.<\/li>\n<\/ul>\n<p>A RESTful web service must define:<\/p>\n<ol>\n<li>Base URI (e.g. http:\/\/example.com\/resources).<\/li>\n<li>Supported data type (e.g. JSON, XML).<\/li>\n<li>Supported operations using HTTP methods (e.g. GET, PUT, POST, or DELETE).<\/li>\n<li>API that is hypertext driven.<\/li>\n<\/ol>\n<span id=\"References\"><h1>References<\/h1><\/span>\n<ul>\n<li>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Representational_state_transfer\">Wiki<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/www.oracle.com\/technetwork\/articles\/javase\/index-137171.html\">RESTful Web Services<\/a><\/p>\n<p>&nbsp;<\/p>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Intro Representational state transfer (REST) is a style of software design architecture. RESTful Constraints In order to be RESTful, the architecture must comply to the following contraints. Client-server: Separation of concerns into client and server (loose coupling): Client focuses on &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=3782\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-3782","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-Z0","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3782","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3782"}],"version-history":[{"count":6,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3782\/revisions"}],"predecessor-version":[{"id":3796,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/3782\/revisions\/3796"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}