WCF Services—Understanding Service Contracts


Jump to: navigation, search
Visual C# Tutorials
.NET Framework Tutorials

WCF Services

© 2007 Chris Peiris, Dennis Mulder

Understanding Service Contracts

Service contracts, one of the Cs in the ABCs of WCF, are what are advertised to the consumers of your services. This advertisement generally takes place through a schema and a contract definition that supports a standardized method for publishing the service contract (along with data contracts). Today, that schema is either a Web Services Description Language (WSDL) contract or a WS-MetadataExchange (MEX) contract. These formats are industry-supported, open specifications. These specifications are located at the following locations:

WSDL: http://www.w3.org/TR/wsdl
MEX: http://schemas.xmlsoap.org/ws/2004/09/mex/


WSDL AND WS-METADATAEXCHANGE
WSDL is an XML Schema–based description of supported operations and messages for an endpoint.

MEX represents a message exchange protocol that allows the discovery of WSDL, WS-Policy, or XML Schema associated with a target namespace. More information is available at the following location: http://specs.xmlsoap.org/ws/2004/09/mex/WS-MetadataExchange.pdf.


Note For COM interop, a third type of contract exists—a typed contract.


The service is basically that, a service—something, perhaps a behavior, that takes place on behalf of another system. Services themselves can be a variety of types and generally fall into either informational or action oriented.

Platform and framework vendors have implemented the tools and libraries that can leverage these standardized contracts to provide a more seamless integration experience amongst the service provider and the consumers (sometimes referred to as receivers and senders). This is what WCF provides in its metadata model: the ability to both define and publish as well as consume these standardized schema definitions. It is possible, in WCF, to provide that support both programmatically at runtime and declaratively at design and configuration time.

WCF provides the standards and tools support primarily through SvcUtil.exe. This utility is the primary code and metadata interpretation tool. That, in combination with the WCF framework’s ability to leverage reflection to interrogate types adorned with the appropriate attributes, makes generating and using the WCF framework less complicated than before. Figure 4-1 illustrates how service metadata is consumed by SvcUtil.exe for proxy generation; additionally, the same metadata is leveraged by the WCF framework for runtime interaction.


Image:7028f0401v1.jpg
Figure 4-1. Metadata publishing and client code generation


Previous_Page_.gif Next_Page_.gif

Share this page
  • del.icio.us
  • Facebook
  • Google+
  • StumbleUpon