Welcome!

Eclipse Authors: Pat Romanski, Elizabeth White, Liz McMillan, David H Deans, JP Morgenthal

Related Topics: Eclipse, Microsoft Cloud

Eclipse: Article

Web Services Manifesto - RESTful Architecture and Programmable Web

REST is an architectural decision, it is not a protocol or a wire format

Let's take a look at a sample of what RESTful URLs might look like. In this sample, let's "RESTify" a help desk service. This help desk service is responsible for managing support tickets. Each support ticket also has a list of work items that contain a log of the work done by support personnel on that ticket. The help desk service also needs to support searching, but in a RESTful manner. This is done by considering the collection of search results to be its own resource. Here are some sample RESTful URLs:

URL Method Presumed Action
/helpdesk/tickets GET Returns a list of all help desk tickets
/helpdesk/tickets/100329312 GET Returns a payload representing just the ticket with a primary key of 100329312.
/helpdesk/tickets POST Creates a new ticket based on the payload in the HTTP POST body
/helpdesk/tickets/100329312 PUT Modifies the ticket with ID of 100329312.
/helpdesk/tickets/100329312/workitems GET Retrieves a log of all activity belonging to the given ticket.
/helpdesk/tickets/100329312/workitems/15 GET Retrieves work item #15 belonging to the given ticket
/helpdesk/tickets/100329312/workitems POST Creates a new work item for an existing ticket
/helpdesk/tickets/100329312/workitems/15 PUT Modifies work item #15
/helpdesk/tickets/100329312 DELETE Deletes ticket 10032912. Assumed that all related/child data will also be deleted in this operation.
/helpdesk/tickets/searchresults/bob GET Runs a keyword query against the phrase ‘bob’ on all tickets in the system

Another common use of REST is to use a slash (/) or semi-colon (;) to further subdivide a resource into views. For example, if you wanted to look at the list of helpdesk tickets but you wanted the "newunassigned" view (which is a really handy view to have!), then you might use the following URL:

/helpdesk/tickets/newunassigned

or

/helpdesk/tickets;newunassigned

A lot of Ruby folks seem to dislike the semi-colon syntax as they think it's "old school", but I like it as it visually distinguishes between a sub-view of a resource and an actual sub-resource. This gives different weight to the "newunassigned" sub-view than a sub-resource like "orderitems".

So how do you go about taking a problem domain and converting it into a service that adheres to RESTful architecture principals? Here's a few guidelines that I use when doing this myself:

  1. Identify Resources
    In this step you want to take a look at your problem domain and the data flowing through your system and see if you can identify the resources available to clients that will eventually be exposed via the service.
  2. Identify how client applications will use resources
    Once you have the list of resources, construct a set of use cases for how client applications will access those resources. This is often an overlooked step but it can be extremely englightening and highlight potential areas where your list of resources may need to be re-organized. Remember that resources are logical resources. If you find you have a 1:1 mapping between SQL tables and resources, you need to go back to the drawing board.
  3. Construct RESTful URL schemes (service contract)
    Using the information obtained in steps 1 and 2, build your URLs. These URLs are essentially the service contract for your RESTful service. Think of it as really, really simple WSDL - just a list of URLs. At this point, don't worry about the message payload format - you can build that later.
  4. Utilize REST URLs in test cases/sample scenarios
    Now that you have your URLs, run through some sample scenarios and use cases for your client application. Usually what happens is I find that I've got about 75% of your URLs right but the rest need work.
  5. Refine
    Finally, take the knowledge you gained in step 4 and repeat steps 1 through 4 until you can get through step 4 without finding any obvious flaws in the URL scheme. Now you can get down to the dirty business of defining your payloads (probably with XSD if you're doing a regular POX implementation) and actually coding up the service and client.

So what does all this mean and why am I posting this? The Web Services scene has changed tremendously since I first started this blog a couple of years ago. A couple of years ago I didn't know much about REST, I wasn't doing anything with social networking, and most people in the industry were thinking, "Web Services? WTF. Just another stupid fad." They couldn't have been more wrong.

So now I'm taking my thoughts on Web Services applications from having spent the last 6 years of my life building them. I remember back in the good old days when they weren't called Web Services and what we were doing was "hacking HTTP to take XML payloads", probably because we were building distributed systems that couldn't communicate properly via DCOM or CORBA. We've come a long way since then and I want to do this series of blog posts covering my thoughts on Web Services as they stand now. This is all my own personal opinion, so feel free to ignore it or flame it, I'm doing this as much for my own edification as I am for yours ;)

Enjoy, and more posts will be forthcoming!

More Stories By Kevin Hoffman

Kevin Hoffman, editor-in-chief of SYS-CON's iPhone Developer's Journal, has been programming since he was 10 and has written everything from DOS shareware to n-tier, enterprise web applications in VB, C++, Delphi, and C. Hoffman is coauthor of Professional .NET Framework (Wrox Press) and co-author with Robert Foster of Microsoft SharePoint 2007 Development Unleashed. He authors The .NET Addict's Blog at .NET Developer's Journal.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


IoT & Smart Cities Stories
CloudEXPO New York 2018, colocated with DXWorldEXPO New York 2018 will be held November 11-13, 2018, in New York City and will bring together Cloud Computing, FinTech and Blockchain, Digital Transformation, Big Data, Internet of Things, DevOps, AI, Machine Learning and WebRTC to one location.
Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settlement products to hedge funds and investment banks. After, he co-founded a revenue cycle management company where he learned about Bitcoin and eventually Ethereal. Andrew's role at ConsenSys Enterprise is a mul...
DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
Disruption, Innovation, Artificial Intelligence and Machine Learning, Leadership and Management hear these words all day every day... lofty goals but how do we make it real? Add to that, that simply put, people don't like change. But what if we could implement and utilize these enterprise tools in a fast and "Non-Disruptive" way, enabling us to glean insights about our business, identify and reduce exposure, risk and liability, and secure business continuity?
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
DXWorldEXPO LLC announced today that Telecom Reseller has been named "Media Sponsor" of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
@DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time t...
DXWorldEXPO LLC announced today that "IoT Now" was named media sponsor of CloudEXPO | DXWorldEXPO 2018 New York, which will take place on November 11-13, 2018 in New York City, NY. IoT Now explores the evolving opportunities and challenges facing CSPs, and it passes on some lessons learned from those who have taken the first steps in next-gen IoT services.
SYS-CON Events announced today that Silicon India has been named “Media Sponsor” of SYS-CON's 21st International Cloud Expo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Published in Silicon Valley, Silicon India magazine is the premiere platform for CIOs to discuss their innovative enterprise solutions and allows IT vendors to learn about new solutions that can help grow their business.