Matthew Adams left a comment on my last post disagree with my characterisation about services being more to do with messages as opposed to remote procedure calls (RPC). It was a good question that I thought was worthy of a lengthier response.
What I was suggesting in the original post is that overtime there will continue to be a move towards services that use messages, and in particular SOAP messages based on the XML Infoset, rather than RPC style calls over time. SOAP because it gives a broader reach for interoperability because of it's lowest common denominator approach and associated standards. Messaging because it gives more flexibility in terms of what is sent and the message exchange patterns that are supported.
The Great SOA Definition Debate
I've been trying to get away for getting into a debate about what services are, mainly because I haven't found a useful definition of service that says more than 'it's a great idea to have blocks of code that do something' and when designing these blocks of code, encapsulation and loose coupling are good practices.
By Matthew's definition a service is something that can do something, at a particular addressable location on a particular protocol, with a particular message format, in a such a way as the consumer doesn't have to care about how that something is done.
Using this definition of a 'service' it is true that the service doesn't have to be implemented as a 'message' end-point. It is possible to implement these 'services' in ASMX web services, in-process .NET classes and remotable objects. The problem is that these choices can impact the amount that the consumer has to know about the way the service is called, if not how it is implemented.
Don's Definition of Services
I like Don Box's definition of a service as a 'program that you communicate with using messages'. These messages are SOAP messages based on the XML Infoset (a logical view of an XML document - angle brackets and text representations may or may not be involved).
The beauty of using SOAP messaging is that it is a lowest-common denominator of solving the problems involved with providing a service:
- How do we address the service, which protocol should we use to talk to it? (WS-Addressing)
- How do we describe the format of the messages that are sent and received? (SOAP)
- How do we describe the format of the contents of these messages (WSDL, XML Schema)
- How do we describe the pattern of the messages that are exchanged? (WSDL)
- How do we describe the other characteristics we need to successfully talk (WS-Policy)
What's wrong with RPC end points?
My main issue with RPC end points is interoperability and flexibily. RPC-style calls to RPC-end points in Matthew's terminology calls can do all of these things, but they are more likely to do it in a less-interoperable way that requires greater knowledge of the underlying platform, protocol or programming model (for example you may need to agree on the binary representation of the parameters used in the procedure call which may mean sharing DLL's or worse, an entire development platform).
Of course any remote procedure call can be thought of as just a particular kind of message. So it's possible to create services that are based around RPC-style calls made within a message (which is how ASMX web services work today). Within web services there are two types of SOAP message format - RPC and document. As Yasser Shohoud points out in his article RPC/Literal and Freedom of Choice, RPC formatted SOAP messages are just a subset of the document formatted (I'd argue message-based) SOAP messages . As he says, ASMX web services show it's possible to use a document style message format but with an RPC programming model.
[Update: See Shawn Smith's post on this topic. In the last section of this post I wasn't very clear about the distinction between SOAP message formats and message exchange patterns. My point was that it is a better idea to implement more flexible approaches to both the message format and the message exchange patterns because the more flexible approach can accommodate the more rigid approach. In this sense the SOAP Document format can accommodate the SOAP RPC message format and the asynchronous message exchange patterns can accommodate RPC message exchange patterns (synchronous request/reply).
Ultimately, it's not worth getting too fussed up about this as both the ASMX and Indigo programming model will support you whichever way you'd like to work. You can write services based around asynchronous messages or using synchronous request/response (stop-and-wait) RPC-style calls. As I said at the start of this post, over time I believe there will be a movement away from synchronous RPC calls towards asynchronous messaging.]