It's hard to question the status of service-oriented architecture as one of the tech industry's latest buzzwords. CIOs want it, and developers wonder what they have to do to implement it.
The main idea behind WCF, Lowy told attendees of the .NET 3.0 Roadshow, a Dr. Dobbs seminar that came to the Boston area last week, is to provide "off-the-shelf plumbing" for service-oriented programming and leave developers more time for actual business logic.
"Developers spend 95% of their time on something that no one cares about," Lowy said in reference to plumbing. "Because nobody cares about plumbing, developers do not get compensated for good plumbing….You end up with a big ball of duct tape and say, 'That's my application.'"
Along with this off-the-shelf plumbing, which will be described below, WCF provides interoperability -- based on industry WS*, or Web services, standards -- and extensibility, since those standards are open. This, Lowy said, makes WCF the most comprehensive implementation of WS* standards now available.
At the most basic level, WCF sits on top of the CLR, or Common Language Runtime, and sends SOAP messages from a client to a service via a proxy, and vice versa. A proxy is CLR interface and a class representing a service.
"You want to make every class a service, not just at the outmost boundary of your system. You can take advantage of the standard plumbing," Lowy said. Were a client to receive the service directly, that would require custom plumbing.
Each WCF service has several important characteristics:
- Address. This identifies where the service is, where the message is going and which transport protocol to use.
- Contract. This defines what a service can do. A contract looks, feels and behaves like a C# class, Lowy said. Contracts are written using an opt-in model -- that is, by default no attributes are selected. "Writing a contract is 80% of what WCF programmers will every have to know," he noted.
- Hosting. A WCF service must be hosted in a Windows process, or host process. Lowy said this can be provided by IIS, which should not be used for intranet applications; by self-hosting, which requires hand-coding of time management, identity management and application pooling, or by Windows Activation Service, or WAS, which does the aforementioned automatically but is only available for Windows Vista server.
- Binding. A binding brings together a service's communication patterns, protocols, encoding, security, reliability and transaction. There are roughly 100,000 different combinations of these, Lowy said. Fortunately, WCF offers nine out of the box; each of the nine can be further customized, and developers can define new bindings as well.
- Endpoint. This brings together a service's address, binding and contract as a service's interface. For a service and a client to exchange a message, both must have the same endpoint; an exchange of metadata makes this possible, Lowy said.
Once each of the above characteristics has been defined, a client and service are ready to exchange a message. For information on how WCF services handle client requests and on how to secure WCF messages and channels, read .NET 3.0 Roadshow: Instance management, security in WCF.