views:

451

answers:

3

We are having a REST WCF service. we want the save operation on this REST service to be in transaction. Is there a way to pass Transaction object over the wire to REST WCF service?

+1  A: 

Transaction support in WCF is handled by means of one of the many WS-* standards, and those only apply to SOAP - I highly doubt the webHttpBinding will be supporting transactions per se.

You might want to check into the ADO.NET Dataservices, though, which are a layer on top of WCF REST.

See a blog post by the ADO.NET DataServices team about this.

Marc

marc_s
+3  A: 

Here is a quote from Roy Fielding, the guy who invented the term REST

If you find yourself in need of a distributed transaction protocol, then how can you possibly say that your architecture is based on REST? I simply cannot see how you can get from one situation (of using RESTful application state on the client and hypermedia to determine all state transitions) to the next situation of needing distributed agreement of transaction semantics wherein the client has to tell the server how to manage its own resources.

...for now I consider "rest transaction" to be an oxymoron.

This is from a message on the REST-discuss list from June 9th, 2009. I can't provide a link because Yahoo groups is useless.

Darrel Miller
Ok, so Fielding should explain (clearly, which is a task in itself) how am I supposed to tell the server: create these two resources, but at the same time, instead of create first this resource, then this other resource.
Stefano Borini
POST /MyResourcePairsI would give you a more real example but you will find that in most cases where a transaction needs to occur, there is a single noun that the user uses to refer to that event. Therefore, from the end-user's perspective, what you are describing very rarely exists.
Darrel Miller
A: 

Here is a recent discussion about the topic: http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataservices/thread/e66651c0-9202-4049-a8f4-55971b8b359d

Basically it says: A single request does not support transactions and it doesn't make sense to support them since only one entity and CUD operation is involved in a single POST/PUT/DELETE request. But transactions can be implemented on server side by:

  • using batch requests (a whole bundle of POST/PUT/DELETE requests being sent in one step from client to the server)
  • and leveraging the processing pipeline (begin a transaction in the Processing event and commit/rollback the transaction in the Processed event)
Slauma