Share via


Using Contracts in Workflow

This topic applies to Windows Workflow Foundation 4 (WF4).

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.

Note

.NET Framework 4 does not allow you to write workflow services using an existing contract definition without some additional tooling support. You cannot use an existing WCF service contract to generate a Workflow service contract. Workflow service contracts are created by the contract inference process discussed previously. Message contracts and data contracts are fully supported, however.

See Also

Tasks

How to: Create a Workflow Service with Messaging Activities

Concepts

Messaging Activities

Other Resources

Workflow Services