Joel's SharePoint Architect Blog

SharePoint 2010, MOSS & WSS Tips and Consultancy Tales

Subscribe Subscribe  View Joel Jeffery's profile on LinkedIn
joelblogs.co.uk | joelj.co.uk | joeljeffery.co.uk | jfdiphoenix.co.uk

Posts Tagged ‘Web Services’

REST vs SOAP/WS-* – David Chappell

Thu, 15 Nov 2007 17:10:48 GMT

David Chappell

Chappell Associates

 

David gave a presentation in 2002 at TechEd EMEA comparing REST and SOAP. He made a mistake. He didn’t decry SOAP as devil-worship. The result was a mailboxful of hate from the REST clan. RESTaferians, David calls them. He decided that he’d just ignore the hell out of them. Which he did. For a few years.

 

But now…

 

Things are changing. The number of scenarios that REST may be the right choice is increasing.

 

Personal Experience

I first wrote a REST service back in 1998. It was a classic ASP page that took a query string argument that gave me different Xml data back based on that argument. I used this to fill a "data island" in an IE4 Html DOM. It was kind of cool then, but I could see the technique would have limitations. If I wanted to do more than just read data, how would I enforce what these arguments meant? Wasn’t until 1999 / 2000 that SOAP (which originally stood for Simple Object Access Protocol…) started appearing. I knew it was something more bullet-proof that my knocked-up, poxy ASP page.

 

REST and WCF

Using GET verbs, Uri notation

Example GET www.barclays.co.uk/Accounts/2

David compares this to a SOAP version of the same request, complete with <Account>2</Account> nodes in the request and SOAP payload excess baggage.

 

The Principles of REST

Two core principles:

  • Everything is accessed through a uniform interface
  • All data (resources) is identified with a Uri

Some secondary principles:

  • Be stateless
  • Be cacheable where possible

 

RESTful Web Services, by Leonard Richardson and Sam Ruby

 

WCF Access via REST

Here’s the REST equivalent in as a WCF interface:

[ServiceContract]

Interface Iaccount

{

[OperationContract]

[WebGet]

int GetBalance (string account);

 

[OperationContract]

[WebInvoke]

int UpdateBalance(string account, int amount);

}

 

WCF can also support sending binary, RSS, ATOM and JSON over a channel using the WebHttpBinding.

 

The Semantics of Http Verbs

 

A closer look shows that REST has got a few complications.

 

REST typically depends on Http’s verbs

  • Primarily PUT, GET, POST and DELETE

The semantics of GET are well defined

  • Http GET is idempotent… ?

 

However, the other Http verbs are not very well defined. And POST is just a big, undefined, black hole. WCF only supports [WebGet] (using Http GET) and [WebInvoke] (which defaults to POST but can be overridden).

 

Now, David contends that Http GET is idempotent. I take issue with this. Idempotency states that you can invoke an operation multiple times and it does the same thing and it should do this without side effects. Additionally, idempotency implies that each message should get there once and once only. It’s that last point that I don’t think GET can guarantee, thanks to the nature of TCP/IP, the Interweb and replays.

 

SOAP vs REST

 

SOAP

REST

Exposing operations

Exposing data

High barrier to entry

Low barrier to entry

 

RESTful Data Access: Example – Amazon S3

The complete interface to S3 is:

  • GET Object
  • GET Bucket
  • GET Service (your "root directory")
  • PUT Object
  • PUT Bucket
  • DELETE Object
  • DELETE Bucket
  • HEAD Object (modified date etc)

 

Problems with REST

In the banking example, you’ve got GET Account, GET (or POST) UpdateBalance. These are all about a single entity. What are you meant to do with TransferFunds()? This implies two resources, and Uri’s can’t stretch to this. Current practice is to have a Uri that represents the operation:

 

This is potentially a problem for anyone who wants to be religious about REST. Is this against their religion? Exposing an operation as a resource? I’m not sure, neither is David. But I’m not sure it’s important.

 

Bigger Problems

I have bigger issues with REST:

  • Contracts. Can we have one? Please? Not in REST.
  • Security infrastructure: no contracts, so this isn’t defined either.
  • Reliable transmission: no contracts, so this isn’t defined either.
  • Transactions: no contracts, so this isn’t defined either.
  • Policy: no contracts, so this isn’t defined either.
  • BUT…
  • …I still can’t believe HTTP GET is idempotent. At a TCP level, under extreme load conditions, I’ve heard of "ghost" GETs being received multiple times. OK – the mathematical definition of the word idempotent doesn’t include the "exactly one message" refinement, but it’s what the BizTalk guys mean by it, so it’s good enough for me.

 

In practice, to me this means REST is for data and browser-based mash-ups.

 

David argues that REST maybe be best for the Internet, but probably not for the enterprise. Problem is, if we’re moving to S plus S or SaaS, isn’t the enterprise moving to the Internet?

 

Technorati Profile

Technorati Tags: ReST, SOAP, TechEd 2007, Web Services, WS*

Service Taxonomy: A Common Language for SOA – Shy Cohen

Tue, 13 Nov 2007 13:06:11 GMT

An excellent session. It did degenerate after a while into an architectural naval-contemplation session, but Shy did come up with one of the most succinct expressions of the Autonomy tenet of services:

"Don’t confuse autonomy with independence. Services are autonomous, but not necessarily independent. It’s like countries. They are politically autonomous entities, but they depend upon other countries to exist. It’s why we have import and export."

 

A Framework for Taxonomy

 

Shy proposes a framework to help us organise services across an enterprise.

 

clip_image001

 

Bus Services

Two different kinds of services – shown in orange above, Bus Services are part of the supporting distributed computing infrastructure and not specific to any application.

Utility Services

  • Offer message transfer facilities
  • Message routing, publish subscribe, etc

Communication Services

  • Offer services unrelated to message transfer
  • Service discovery, federated security, etc

 

clip_image002

 

Application Services

These are coarse-grained, high-level application building blocks,:

  • Entity Services – Manipulate business services; e.g. Employee, Purchase Order, Conveyer Belt
  • Capability Services and Activity Services – Functional building blocks of the application, Verify Customer Credit
  • Process Services – Compose and orchestrate Entity, Capability and Activity Services to implement business processes – e.g.  Authorise Holiday, Process PO.

 

clip_image003

 

In Detail – Bus Services – Communication Services

Role

  • Transport messages in, out, within the system; across network or protocol boundaries
  • Not Concerned with the content of the messages; schema agnostic; may use message parts to determine message advancement

Interfaces

  • Generic for receiving and forwarding messages (interface is message-schema agnostic
  • Management and monitoring interfaces

 

Characteristic

Details

State Management

No app state. Self state configured by the applications

Monitoring and Diagnostics

Analysis of message traffic patters. Error rate reporting

Security

App-specific requirements, regulatory etc, with permissions at App, Use or App-User

Errors

Network level, e.g. Round-robin

Construction and Management

A commodity (build centrally or buy) that’s built to last and is centrally managed

 

In Detail – Bus Services – Utility Services

Role

  • Shared Infrastructure – not message transport
  • Generic, non-messaging, app-agnostic services
    • e.g. STS, discovery, message schema translation
  • Configured on how to perform operations for the app
    • e.g. Schema mapping for schema translation service

Interfaces

  • An interface specific to the services functionality
    • Process messages sent to it
    • Message exchange is typically request-response
  • May also have management and monitoring interfaces

 

Characteristic

Details

State Management

No app state. Self state configured by the application

Monitoring and Diagnostics

Analysis of service requests. Error rate reporting.

Security

App-specific requirements, regulatory etc. With permissions at App, User or App-User

Errors

Errors handling is specific to the service’s functionality

Construction and Management

A commodity (build centrally or buy) that’s built to last is centrally managed

 

In Detail – Application Services – Entity Services

Role

  • To unlock and expose the business entities of the system
    • Data-centric components ("nouns") of the business process
    • Expose the information stored in one or more data stores in the system through a service interface
  • Abstract data stores
    • e.g. SQL Server, Active Directory, etc
  • The information being managed is of general interest
    • Used in several or even all the systems in the organisation

Interfaces

  • CRUD interface at the entity level
    • Operations may depend on access and modification restrictions
    • Entities are structured types
    • Underlying data stores typically relational or hierarchical
  • Additional domain-specific operations
    • Addressing problem-domain
    • Support app’s features and use-cases
      • e.g. FindCustomerIdByPhone
  • Functional Interface; i.e. CRUD + domain specific functionality

 

Characteristic

Details

State Management

Manage the persistent state of the system, typically for longer than any single process.

Consistency

Atomic transaction and reservation pattern

Security

App-specific access restriction requirements, regulatory etc. Permission at App/User levels

Errors

Seeking alternative data sources,. Error policy part of SLE/SLA

Construction and Management

Built in-house to last (SW factory, DB feature). Used by multiple apps across the enterprise.

 

In Detail – Application Services – Capability Services

Role

  • Represent business-level capabilities of the organisation
  • Action-centric building blocks of the organisation’s business processes
    • "Atomic verbs"

Interface

  • Interface specific to the capability they represent
  • May thinly wrap an existing legacy) or newly acquired business capability
    • Facade service is opaque
    • Underlying capability can be replaced without changing the service interface use to access it
    • Facade service is considered the Capability Service

 

< td style="border-right:#a3a3a3 1pt solid;padding-right:4pt;border-top:#a3a3a3 1pt solid;padding-left:4pt;padding-bottom:4pt;vertical-align:top;border-left:#a3a3a3 1pt solid;width:1.772in;padding-top:4pt;border-bottom:#a3a3a3 1pt solid">

Security

Characteristic

Details

State Management

Manage transient state, for shorter than the duration of the process

Consistency

Atomic transaction (flowed downstream) and Reservation pattern (over downstream store)

App-specific access restriction requirements, regulatory etc. Permission at the App level.

Errors

Error compensation part of SLE/SLA

Construction and Management

Built / Buy / Lease to last (workflow or code). Managed centrally.

 

In Detail – Application Services  - Activity Services

Role

  • Business level capabilities or action centric business logic elements ("building blocks")
    • Used in a single composite app or a single solution
    • May evolve into Capability Services
  • Forces impacting creation of Activity Services
    • Decomposition of a complex process
    • Enabling reuse of functionality in several places; within a single process service or across multiple process services
    • Pressures can come from architecture/implementation requirements, organisation forces within the business, security requirements, regulatory requirements etc.

 

Interfaces

  • Service interface is specific to the capability
  • Possible for Activity Services to wrap existing units of functionality

 

Characteristic

Details

State Management

Manage transient state, wrapping cases will actually hold app state

Consistency

Atomic transactions used internally; Reservation pattern externally

Security

App-specific access restriction requirements, regulatory etc. Permission at the App level.

Errors

Error compensation part of SLE/SLA

Construction and Management

Built in house to last. Used by single apps and managed as such. Over time, may become a Capability Service

 

In Detail – Application Services – Process Services

Role

  • Combine data-centric and action-centric building blocks to implement business processes
    • Compose the functionality of Activity Services, Capability Services and Entity Services; tied together with business logic.
    • Designed to enable process agility
  • May be composed into the workflows of other Process Services
    • Because of their long running nature, they are not categorised as Capability or Activity Services; also they implement an agile process.

 

Interfaces

  • Often fronted with a UI that initiates, controls and monitors the process
    • Service interface typically geared towards consumption by presentation tier
    • Level of granularity designed for user-facing, front-end applications
  • Monitoring the business process (BAM)

 

Characteristic

Details

State Management

Manage app state for the duration of the process

Consistency

None, or reservation pattern if recomposing

Security

User specific access restriction

Errors

Error handling is an integral part of the process being implemented

Construction and Management

Built in house to change (e.g. Workflow). Typically used by a single app and managed per application. May be recomposed into another process.

 

Summary

 

The taxonomy provided here just gives very high level holding places for your services. The important part here is that we all start using the same names for things. When we have a large number of services, we will find this taxonomy does not provide a suitable level of granularity and distinction between them.

 

One way round this would be to devise a lower level taxonomy orthogonal to this one, as and when we need the extra flexibility to our vocabulary. So, you may decide to add a level of granularity based on business functionality. For instance, Customer Activity Services, or Purchase Order Process Services.

 

Technorati Profile

Technorati Tags: SOA, TechEd 2007, Web Services