building workflow services in .net 3.5
DESCRIPTION
Building Workflow Services in .NET 3.5. CLAEYS Kurt, ORDINA. www.devitect.net. Agenda. Windows Communication Foundation Overview. Client. Service. A. B. C. A. B. C. C. B. A. A. B. C. Address Where?. Binding How?. Contract What?. WCF Contracts. [ ServiceContract ] - PowerPoint PPT PresentationTRANSCRIPT
Building Workflow Services in .NET 3.5CLAEYS Kurt, ORDINAwww.devitect.net
Agenda
Windows Communication Foundation Overview
ServiceClient
ABC
AddressWhere?
ContractWhat?
BindingHow?
CBA
CBA
CBA
WCF Contracts[ServiceContract] public interface IKBO{ [OperationContract] void RegisterCompany(CompanyFile data);}
[DataContract]public class CompanyFile{ [DataMember] public string companyName { get; set; } [DataMember] public string VATID { get; set; } }
Windows Workflow Foundation Overview
WorkflowActivities
Activity Library
Workflow Runtime
Persistence Service
WorkflowServiceHost - Workflow
WorkflowServiceHost
Workflow
WCF Endpoint
WCF Endpoint
ServiceHostClient
Service
WCF
CBAWCF
CBA
Start – More Input – Action !
Start
Action
WorfklowService
WaitMore Input
Service
Client 1
Client 2
ReceiveActivity
•Activity that implements an operation defined by a Windows Communication Foundation (WCF) service contract.•To implement service behavior : add child activities to the ReceiveActivity
Client
Binding an operation contract to a ReceiveActivity
•ServiceOperationInfo property•Add Contract = Workflow First•Import = Contract First
Contract First vs Workflow First approach
•Contract First• You have a WCF contract (=interface)• You map receiveActivities in workflows to the
operations in the contract• SOA
•Workflow First Approach• No WCF contract present• Create contract as you model the workflow• More agile
ContextExhange Protocol
Client 1
Client 2 More Input
instanceID
WorkflowPersistenc
eDB
“creates” instance
“follows” instancesome data + instanceIDEC969B-4239-427E-BB0A-9F7E5610A1F0
some data + instanceIDEC969B-4239-427E-BB0A-9F7E5610A1F0
some dataStart
CanCreateInstance
•CanCreateInstance (true/false)• Gets or sets whether the operation on a
ReceiveActivity causes a new workflow service instance to be created or to participate in an already instantiated workflow.
Persisting the instance
- Creates an InstanceID-Sends it to the Client
- Allows to persists WF instance
- Expects an InstanceID - Load persisted WF instance
CanCreateInstance = false
CanCreateInstance = trueStart
More Input
EC969B-4239-427E-BB0A-9F7E5610A1F0
SendActivity
•Activity that models the synchronous invocation of a service operation.•Use ChannelToken as reference to client endpoint
Service
ChannelToken - Endpoint
<client> <endpoint address="http://localhost:4321/Foo" binding="basicHttpBinding" bindingConfiguration="" contract=“IFOO" name=“TheEndpointForTheService" /></client>
WorkflowServiceHost
WorkflowServiceHost host;host = new WorkflowServiceHost(typeof(TheWorkflow));
host.Open();
Participating ClientDossierInterface.IDossier proxy;
System.ServiceModel.Channels.Binding b;b = new NetTcpContextBinding();EndpointAddress ea;ea = new EndpointAddress("net.tcp://localhost:9876/TheWorkflow");
proxy = ChannelFactory<DossierInterface.IDossier>. CreateChannel(b, ea);
System.ServiceModel.Channels.IContextManager cm;cm = ((System.ServiceModel.IContextChannel)proxy). GetProperty<System.ServiceModel.Channels.IContextManager>();
var d = cm.GetContext();
d["instanceId"] = textBox1.Text;
cm.SetContext(d);
proxy.PaymentReceived();
DEMO
Demo Scenario
Step 1User starts the process by filling in data in a webapplication
Step 2Process StartedGenerate paymentreferenceStep 3
User gets paymentreference Step 4Process waits for payment for amount of timeStep 5
User pays Step 6Process receives payments and continues
Step 7Process data is send to external service
Wrap-up
What to remember about workflow services
•Workflows Services is an easy technology to build processes that integrate WCF Services•Start with creating interfaces (= contract first approach)•Share interface to all participants •Importance of the instanceId•Database for persisting workflows makes the process long running !•Have a delay activity for every ‘waiting for input’ scenario•Have a look at WCF 4.0 and Dublin !
Links
Some links to get you started ...
•This Example •http://www.devitect.net/techdays09
•Workflow Services (Foundation)•http://msdn.microsoft.com/en-us/magazine/cc164251.aspx
•Context Exhange Protocol •http://msdn.microsoft.com/en-us/library/bb924468.aspx
•WF and WCF integration in .NET 3.5•http://channel9.msdn.com/shows/The+EndPoint/WF-and-WCF-integration-in-NET-35/
•Workflow Services Samples (WF)•http://msdn.microsoft.com/nl-be/library/bb943473(en-us).aspx
•Workflows, Services, and Models, A First Look at WF 4.0, “Dublin”, and “Oslo”•http://msdn.microsoft.com/en-us/library/dd200919.aspx
Q/A