Thứ Năm, 24 tháng 1, 2013

Web services are dead -- long live REST.


Once, an endless parade of Web service protocols promised to guarantee any system could talk to any other. In the end, we got much of that interoperability via simpler means


Remember the heyday of Web services, when we were always just one specification away from perfect interoperability? Ultimately, that towering stack of protocols collapsed under its own weight. SOAP and XML generally are ridiculously verbose protocols that began with a commitment to simplicity and gave way to mind-numbing levels of complexity. Add to that the service repository mess: UDDI died an ignominious death, and OASIS's S-RAMP committee can't even create a website that isn't all broken links.
Interoperability Nirvana remains out of reach. What do we have instead? We have the registry called "the freaking Internet." Services are registered as URL handlers, and we execute against them. The XML transmission format was replaced by the format that your browser and mobile devices all learned to speak: JavaScript Object Notation. REST plus JSON over HTTP/HTTPS is the new Web services -- strangely, it's more interoperable without an explicit specification. Instead we make it work like the Internet, and DNS is your service registry.
[ Also on InfoWorld: 9 app dev projects you should cancel in 2013. | Download InfoWorld's PDF of tips and trends programmers need to know in our Developers' Survival Guide. | Keep up with the latest developer news with InfoWorld's Developer World newsletter. ]
We use JQuery/JavaScript/JSON for our UIs nowadays. We can even use Node.js for our business logic. Databases like Couchbase 2.0 and MongoDB speak JavaScript and JSON (or a direct derivative) natively. The beauty of this as an architecture is that we can drop entire layers of object binding and data transformation from our code.
Brought to you by the InternetWhat does this look like? Consider your Order/Line items example.
Save or update the order:
POST http://infoworld.com/example/Order/123

{
   "firstName": "Andrew",
   "middle": "C",
   "lastName": "Oliver",
   "address": {
       "streetAddress": "345 West Main St, Suite 201",
       "city": "Durham",
       "state": "NC",
       "postalCode": 27701
   },
   "LineItems": {
       {
           "type": "widget",
           "sku": "123-456"
       },
       {
           "type": "widget",
           "number": "452-123"
       }
   }
}
Replace the line items of the order:
PUT http://infoworld/example/Order/123/LineItems
{
       {
           "type": "widgetTypeA",
           "sku": "123-456"
       },
       {
           "type": "widgetTypeB",
           "number": "452-123"
       }
   }
More: http://www.infoworld.com/d/application-development/web-services-are-dead-long-live-rest-211395 

Không có nhận xét nào:

Đăng nhận xét