Contract First Workflow Service Development

.NET Framework (current version)
 

Starting with .NET Framework 4.5, Windows Workflow Foundation (WF) features better integration between web services and workflows in the form of contract-first workflow development. The contract-first workflow development tool allows you to design the contract in code first. The tool then automatically generates an activity template in the toolbox for the operations in the contract. This topic provides an overview of how the activities and properties in a workflow service map to the attributes of a service contract. For a step-by-step example of creating a contract-first workflow service, see How to: Create a workflow service that consumes an existing service contract.

The tables in the following sections specify the different WCF attributes and properties and how they are mapped to the messaging activities and properties in a contract-first workflow.

Service Contract Attributes

Property NameSupportedDescriptionWF Validation
CallbackContractNoGets or sets the type of callback contract when the contract is a duplex contract.(N/A)
ConfigurationNameNoGets or sets the name used to locate the service in an application configuration file.(N/A)
HasProtectionLevelYesGets a value that indicates whether the member has a protection level assigned.Receive.ProtectionLevel should not be null.
NameYesGets or sets the name for the <portType> element in Web Services Description Language (WSDL).Receive.ServiceContractName.LocalName should match.
NamespaceYesGets or sets the namespace of the <portType> element in Web Services Description Language (WSDL).Receive.ServiceContractName.NameSpace should match
ProtectionLevelYesSpecifies whether the binding for the contract must support the value of the ProtectionLevel property.Receive.ProtectionLevel should match.
SessionModeNoGets or sets whether sessions are allowed, not allowed or required.(N/A)
TypeIdNoWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)(N/A)

Insert subsection body here.

Operation Contract Attributes

Property NameSupportedDescriptionWF Validation
ActionYesGets or sets the WS-Addressing action of the request message.Receive.Action should match.
AsyncPatternNoIndicates that an operation is implemented asynchronously using a Begin<methodName> and End<methodName> method pair in a service contract.(N/A)
HasProtectionLevelYesGets a value that indicates whether the messages for this operation must be encrypted, signed, or both.Receive.ProtectionLevel should not be null.
IsInitiatingNoGets or sets a value that indicates whether the method implements an operation that can initiate a session on the server(if such a session exists).(N/A)
IsOneWayYesGets or sets a value that indicates whether an operation returns a reply message.(No SendReply for this Receive OR no ReceiveReply for this Send).
IsTerminatingNoGets or sets a value that indicates whether the service operation causes the server to close the session after the reply message, if any, is sent.(N/A)
NameYesGets or sets the name of the operation.Receive.OperationName should match.
ProtectionLevelYesGets or sets a value that specifies whether the messages of an operation must be encrypted, signed, or both.Receive.ProtectionLevel should match.
ReplyActionYesGets or sets the value of the SOAP action for the reply message of the operation.SendReply.Action should match.
TypeIdNoWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)(N/A)

Message Contract Attributes

Property NameSupportedDescriptionWF Validation
HasProtectionLevelYesGets a value that indicates whether the message has a protection level.No validation (Receive.Content and SendReply.Content must match the message contract type).
IsWrappedYesGets or sets a value that specifies whether the message body has a wrapper element.No validation (Receive.Content and Sendreply.Content must match the message contract type).
ProtectionLevelNoGets or sets a value that specified whether the message must be encrypted, signed, or both.(N/A)
TypeIdYesWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)No validation (Receive.Content and SendReply.Content must match the message contract type).
WrapperNameYesGets or sets the name of the wrapper element of the message body.No validation (Receive.Content and SendReply.Content must match the message contract type).
WrapperNamespaceNoGets or sets the namespace of the message body wrapper element.(N/A)

Data Contract Attributes

Property NameSupportedDescriptionWF Validation
IsReferenceNoGets or sets a value that indicates whether to preserve object reference data.(N/A)
NameYesGets or sets the name of the data contract for the type.No validation (Receive.Content and SendReply.Content must match the message contract type).
NamespaceYesGets or sets the namespace for the data contract for the type.No validation (Receive.Content and SendReply.Content must match the message contract type).
TypeIdNoWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)(N/A)

Fault Contract Attributes

Property NameSupportedDescriptionWF Validation
ActionYesGets or sets the action of the SOAP fault message that is specified as part of the operation contract.SendReply.Action should match.
DetailTypeYesGets the type of a serializable object that contains error information.SendReply.Content should match the type
HasProtectionLevelNoGets a value that indicates whether the SOAP fault message has a protection level assigned.(N/A)
NameNoGets or sets the name of the fault message in Web Services Description Language (WSDL).(N/A)
NamespaceNoGets or sets the namespace of the SOAP fault.(N/A)
ProtectionLevelNoSpecifies the level of protection the SOAP fault requires from the binding.(N/A)
TypeIdNoWhen implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)(N/A)

Unsupported service contract features

  • Use of TPL (Task Parallel Library) Tasks in contracts is not supported.

  • Inheritance in Service Contracts is not supported.

Generation of configured messaging activities

Two public static methods are added to the Receive and SendReply activities to support the generation of pre-configured message activities when using contract-first workflow services.

The activity generated by these methods should pass contract validation, and therefore these methods are used internally as part of the validation logic for Receive and SendReply. The OperationName, ServiceContractName, Action, SerializerOption, ProtectionLevel, and KnownTypes are all pre-configured to match the imported contract. In the content properties page for the activities in the workflow designer, the Message or Parameters sections are also pre-configured to match the contract.

WCF fault contracts are also handled by returning a separate set of configured SendReply activities for each of the faults that show up in the Faults FaultDescriptionCollection.

For other parts of OperationDescription that are unsupported by WF services today (e.g. WebGet/WebInvoke behaviors, or custom operation behaviors), the API will ignore those values as part of the generation and configuration. No exceptions will be thrown.

Show: