building workflow services in .net 3.5

23
Building Workflow Services in .NET 3.5 CLAEYS Kurt, ORDINA www.devitect.net

Upload: fritzi

Post on 22-Feb-2016

58 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: Building Workflow Services  in .NET 3.5

Building Workflow Services in .NET 3.5CLAEYS Kurt, ORDINAwww.devitect.net

Page 2: Building Workflow Services  in .NET 3.5

Agenda

Page 3: Building Workflow Services  in .NET 3.5

Windows Communication Foundation Overview

ServiceClient

ABC

AddressWhere?

ContractWhat?

BindingHow?

CBA

CBA

CBA

Page 4: Building Workflow Services  in .NET 3.5

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; } }

Page 5: Building Workflow Services  in .NET 3.5

Windows Workflow Foundation Overview

WorkflowActivities

Activity Library

Workflow Runtime

Persistence Service

Page 6: Building Workflow Services  in .NET 3.5

WorkflowServiceHost - Workflow

WorkflowServiceHost

Workflow

WCF Endpoint

WCF Endpoint

ServiceHostClient

Service

WCF

CBAWCF

CBA

Page 7: Building Workflow Services  in .NET 3.5

Start – More Input – Action !

Start

Action

WorfklowService

WaitMore Input

Service

Client 1

Client 2

Page 8: Building Workflow Services  in .NET 3.5

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

Page 9: Building Workflow Services  in .NET 3.5

Binding an operation contract to a ReceiveActivity

•ServiceOperationInfo property•Add Contract = Workflow First•Import = Contract First

Page 10: Building Workflow Services  in .NET 3.5

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

Page 11: Building Workflow Services  in .NET 3.5

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

Page 12: Building Workflow Services  in .NET 3.5

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.

Page 13: Building Workflow Services  in .NET 3.5

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

Page 14: Building Workflow Services  in .NET 3.5

SendActivity

•Activity that models the synchronous invocation of a service operation.•Use ChannelToken as reference to client endpoint

Service

Page 15: Building Workflow Services  in .NET 3.5

ChannelToken - Endpoint

<client> <endpoint address="http://localhost:4321/Foo" binding="basicHttpBinding" bindingConfiguration="" contract=“IFOO" name=“TheEndpointForTheService" /></client>

Page 16: Building Workflow Services  in .NET 3.5

WorkflowServiceHost

WorkflowServiceHost host;host = new WorkflowServiceHost(typeof(TheWorkflow));

host.Open();

Page 17: Building Workflow Services  in .NET 3.5

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();

Page 18: Building Workflow Services  in .NET 3.5

DEMO

Page 19: Building Workflow Services  in .NET 3.5

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

Page 20: Building Workflow Services  in .NET 3.5

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 !

Page 21: Building Workflow Services  in .NET 3.5

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

Page 22: Building Workflow Services  in .NET 3.5

Q/A