Using Contracts in Workflow

When implementing a service, you define a number of contracts that describe the service and the data that it sends and receives. The data is represented as data contracts and message contracts; both WCF and workflow services use data contract and message contract definitions as part of service descriptions. The service itself exposes metadata (in the form of WSDL) in order to describe the operations of the service. In WCF, service contracts and operation contracts define the service and the operations it supports. However, in a workflow service, these contracts are part of the business process itself; they are exposed in metadata by a process called contract inference.

Contract Inference

When a workflow service is hosted using WorkflowServiceHost, the workflow definition is examined and a contract is generated based on the set of messaging activities found in the workflow. In particular the following activities and properties are used to generate the contract:

Receive Activity

SendReply Activity

TransactedReceiveScope Activity

The end result of contract inference is a description of the service using the same data structures as WCF service and operation contracts. This information is then used to expose WSDL for the workflow service.

See also