Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Server 2008 – Windows Communication Foundation Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK.

Similar presentations


Presentation on theme: "Windows Server 2008 – Windows Communication Foundation Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK."— Presentation transcript:

1 Windows Server 2008 – Windows Communication Foundation Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK

2 Agenda WCF Architecture ContractsBindingsAddressBehaviours Windows Process Activation Service Hosting WF from WCF in IIS 7.0

3 Client Service Clients and Services Endpoint CBA CBA A BC CBA Address Where? Contract What? Binding How? Endpoint Endpoints Address, Binding, Contract Bv Behaviours ServiceHost ClientChannel Runtime Metadata

4 Contracts Service Contract Describes the service endpoints and the operations that can be performed on those endpoints. Data Contract Describes the message serialization. Maps CLR types to schema definition. Message Contract Describes structure of message on the wire. Provides control over the structure of the message.

5 [ServiceContract] public interface IHello { [OperationContract] string Hello(string name); } Service Contract public class HelloService : IHello { public string Hello(string name) { return “Hello ” + name; }

6 [ServiceContract] public interface IIncomingMessage { [OperationContract(IsOneWay=true)] void SendMessage(string name); } Service Contract: OneWay

7 [ServiceContract(CallbackContract=typeof(IOutgoingMessage))] public interface IIncomingMessage { [OperationContract(IsOneWay=true)] void SendMessage(string name); } public interface IOutgoingMessage { [OperationContract(IsOneWay=true)] void ReceiveMessage(string s); } Service Contract: Duplex

8 [ServiceContract] public interface IHello { [OperationContract] [FaultContract(typeof(InvalidNameException))] string Hello(string name); } Service Contract: Faults public string Hello(string name) { if(name != “Dave”) { throw new FaultException ( new InvalidNameException(“Wrong name")); }

9 [ServiceContract] public interface IHello { [OperationContract] string Hello(HelloMessage msg); } Data Contract [DataContract] public class HelloMessage { [DataMember(Name=“From”)] public string from; [DataMember(Name=“From”, IsRequired=true)] public string to; [DataMember] public string message; }

10 Message Contract [DataContract] [MessageContract] public class HelloMessage { [DataMember] [MessageBody] public string from; [DataMember] [MessageHeader] public string to; [DataMember] [MessageBody] public string message; }

11 Bindings Transport PipesMSMQ Custom TCPHTTP Encoders Binary Text Custom Binding HTTP Text TXSecurityRM MTOM Protocol WS-* Custom

12 Standard Bindings Interop Security Session Transactions Duplex Streaming BasicHttpBinding BP 1.1 T WsHttpBindingWS T | S XX WsDualHttpBindingWS XXX NetTcpBinding.NET XXXO NetNamedPipesBinding.NET XXXO NetMsmqBinding.NET XX NetPeerTcpBinding.NET X T = Transport Security | S = WS-Security | O = One-Way Only

13 ASMX/WSE3 WCF WCF ASMX/WSE3 Interop Bindings MSMQ WCF WCF MSMQ WS-* Protocols MSMQ Protocol MSMQ Binding Http/WS Binding WCF WCF WS-* Protocols * Binding

14 Bindings have semantics Session, Duplex, Transaction Flow, Transacted Read, Queued Delivery, Ordered, Assurances Asserting Semantic Requirements in Code [ServiceContract][DeliveryRequirements]Customization ‘Tweak’ existing standard bindings Create completely new bindings Choosing Bindings

15 Addresses http://microsoft.com:80/OrderService/WShttps://microsoft.com:443/OrderService/BPnet.tcp://microsoft.com:808/OrderService/TCPnet.pipe://microsoft.com/OrderService/NP Scheme http, https, net.tcp, net.pipe Host Name microsoft.com Port (Optional) * 80, 443, 808 Base Path /OrderService/ Endpoint Address WS, BP, TCP, NP * - Port Does Not Apply to Named Pipes

16 Service Hosting Options ServiceHost allows for hosting anywhere Console applications Windows applications Windows services IIS provides a scalable host environment Edit a.svc file and point at your service Only HTTP transports in IIS 6.0 All transports in IIS 7.0 (Windows Process Activation Service)

17 class HelloHost { static void Main (string[] args) { ServiceHost host = new ServiceHost(typeof(HelloService)); host.Open(); // Wait until done accepting connections Console.ReadLine(); host.Close(); } Service Hosting http://localhost/HelloService/HelloService.svc Self-host IIS-host

18 Service Configuration <endpoint address=“” binding=“basicHttpBinding" contract="IHello" />

19 demo Windows Communication Foundation

20 Behaviours Behaviours cover the system semantics Service features ConcurrencyInstancingTransactionsImpersonation Deployment features Throttling Metadata exposure

21 Instancing Per Call Single Private Session Shared Session

22 Concurrency MultipleReentrantSingle

23 demo Windows Communication Foundation

24 WAS Activation Activation and health of worker process is managed by Windows Process Activation Service Provides “external” monitoring and recycling Activate over TCP, Named Pipe, MSMQ, or HTTP Provides high availability, managed process for web service based applications

25 WAS In IIS 7.0, Windows Process Activation Service (WAS) manages application pool configuration and worker processes instead of WWW Service in IIS 6.0. This enables the same configuration and process model for HTTP and non-HTTP sites. Additionally, you can run WAS without WWW Service if you do not need HTTP functionality. For example, you can manage an WCF service through a listener, such as NET.TCP, without running the WWW Service if you do not need to listen for HTTP requests in HTTP.sys.

26 Enabling WAS

27 Adding net.tcp binding to IIS 7.0 Add net.tcp binding to “Default Web Site” appcmd.exe set site "Default Web Site" – +bindings.[protocol='net.tcp', bindingInformation='808:*'] Add a new application appcmd add app /site.name:"Default Web Site" /path:/WasDemo /physicalpath: c:\Inetpub\wwwRoot\WasApplication Enable protocols for the application appcmd.exe set app "Default Web Site/WasApplication" /enabledProtocols: http,net.pipe,net.tcp,net.msmq

28 demo Windows Communication Foundation

29 Hosting WF from WCF in IIS 7.0 Implement a ServiceHost extension Override Attach and Detach to start and stop the WorkflowRuntime Derive a new ServiceHost that loads the loads the ServiceHost extension Derive a new ServiceHostFactory to load the new ServiceHost Add the Factory attribute to.svc file

30 demo Windows Communication Foundation

31 .NET Framework 3.5 “Orcas” WF & WCF Integration WCF partial trust support WCF JSON Serialization webHttpBinding to enable Integrate with ASP.NET AJAX Framework WCF POX/REST support Programming against resource-centric applications webHttpBinding to enable WCF RSS/Atom support Add SyndicationBehavior to endpoint Code Name “Orcas”

32 WCF Features Summary AddressBindingBehaviorContract HTTP Transport TCPTransport NamedPipe Transport MSMQ Transport Custom Transport WS-Security Protocol WS-RM Protocol WS-Coord Protocol Duplex Channel Custom Protocol http://... net.tcp://... net.pipe://... net.msmq://... xxx://... ThrottlingBehavior Metadata Behavior Error Behavior Custom Behavior Instancing Behavior Concurrency Behavior Transaction Behavior Security Behavior Request/ Response One-Way Duplex net.p2p://... PeerTransport Externally visible, per-endpoint Opaque, per-service, endpoint, or operation

33 Resources MSDN WCF home page http://msdn2.microsoft.com/en- us/netframework/aa663324.aspx http://msdn2.microsoft.com/en- us/netframework/aa663324.aspx http://msdn2.microsoft.com/en- us/netframework/aa663324.aspx WCF community site http://wcf.netfx3.com/ http://wcf.netfx3.com/ Great WAS article for developers http://msdn.microsoft.com/msdnmag/issues/0 7/09/WAS/ http://msdn.microsoft.com/msdnmag/issues/0 7/09/WAS/ http://msdn.microsoft.com/msdnmag/issues/0 7/09/WAS/

34

35 Windows Server 2008 – Windows Workflow Foundation Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK

36 Agenda What is Windows Workflow Foundation? Architecture & Core concepts Building Workflows Building Activities Runtime Services

37 Windows Workflow Foundation Single workflow technology for Windows Available to all customers of Windows Available for use across a broad range of scenarios Redefining workflow Extensible framework & API to build workflow centric products One technology for human and system workflow Take workflow mainstream Bring declarative workflow to any.NET developer Fundamental part of the Office 2007 Strong workflow partner & solution ecosystem Windows Workflow Foundation is the programming model, engine and tools for quickly building workflow enabled applications on Windows.

38 What is a workflow? A set of activities that coordinate people and / or software... EscalateToManager Example activities…. CheckInventory Like a flowchart…. …organized into some form of workflow. Or a state diagram….or based on rules.

39 Windows Workflow Foundation Key Concepts Host Process Windows Workflow Foundation Runtime Engine A Workflow An Activity Runtime Services Base Activity Library Custom Activity Library Visual Designer Visual Designer: Graphical and code-based construction Workflows are a set of Activities Workflows run within a Host Process: any application or server Developers can build their own Custom Activity Libraries Components Base Activity Library: Out-of-box activities and base for custom activities Runtime Engine: Workflow execution and state management Runtime Services: Hosting flexibility and communication

40 Building a Workflow

41 Workflow Authoring Modes.NET assembly ctor defines workflow Markup Only “Declarative” XOML Markup and Code C#/VB Code Only Application Generated XOML C#/VB XML defines workflow structure logic and data flow XML defines workflow Code-beside defines extra logic Code creates workflow in constructor XOML C#/VB App creates activity tree and serializes Workflow Compiler wfc.exe C#/VB Compiler

42 Flexible Control Flow Rules-driven Activities Step2 Step1 Rule1 Rule2 Data Rules + data state drive processing order Data-driven Simple Conditions, complex Policies Constrained Activity Group State Machine Workflow State2 State1 Event External events drive processing order Reactive, event-driven Skip/re-work, exception handling Graph metaphor Sequential Workflow Step1 Step2 Sequential structure prescribes processing order Prescriptive, formal Automation scenarios Flowchart metaphor

43 Order Processing Example On Order Created On Order Processed Order Created Order Processed Order Shipped On Order Shipped On Order Completed On Order Completed Waiting to Create Order On Order Completed On Order Shipped Order Completed

44 A State Machine Workflow

45 What are Activities? An activity is a step in a workflow Has properties and events that are programmable within your workflow code Has methods (e.g. Execute) that are only invoked by the workflow runtime Think of Forms & Controls Activity == Controls Workflows == Forms Activities fall under two broad categories Basic – steps that “do work” Composite – manage a set of child activities

46 Base Activity Library Base Activities get you started… Designed for modeling control flow & communications IfElse, Delay, While, State, etc. InvokeWebService, InvokeMethod, etc. Custom activities can derive from the Base Activities Base Activities have been built using the same framework that’s available to you as developers

47 Activities: An Extensible Approach OOB activities, workflow types, base types General-purpose Activity libraries define workflow constructs Create/Extend/ Compose activities App-specific building blocks First-class citizens Base Activity Library Custom Activity Libraries Author new activity Out-of-Box Activities Extend activity Compose activities Vertical-specific activities & workflows Best-practice IP & Knowledge Domain-Specific Workflow Packages Compliance RosettaNet CRM IT Mgmt

48 Why build custom activities? Activity is unit of: Execution Reuse Composition Enable workflow modeling Custom activity examples SendEmail, FileSystemEvent, etc. Write custom activities for Reusing workflow logic Integrating with technologies Modeling advanced control flows Modeling various workflow styles Simplicity Flexibility Code Activity InvokeMethod & EventSink Custom Activities InvokeWebService Activity Workflow Execution Logic

49 Example: A SendMail Activity using System.Workflow.ComponentModel; public partial class SendMail : System.Workflow.ComponentModel.Activity { public SendMail() { InitializeComponent(); } protected override Status Execute(ActivityExecutionContext context) { // logic here to send the email return Status.Closed; } public partial class SendMail { public string subject; public string Subject { get { return subject; } set { this.subject = value; } } private void InitializeComponent() // designer generated { this.ID = "SendMail"; }

50 Activity Component Model Each activity has an associated set of components Components are associated through attributes on the Activity Definition Required Optional (defaults provided) // Companion classes [Designer(typeof(MyDesigner))] [CodeGenerator(typeof(MyCodeGen))] [Validator(typeof(MyValidator))] // Behaviors [SupportsTransaction] public class MyActivity: Activity {...} Activity Code Generator Designer Validator Serializer Behaviors

51 Activity Definition Class Class that defines the activity’s properties, events and conditions Defines how the activity manages state Two types of state: Instance state: data is instance-specific Metadata state: data remains the same across all instances State can be managed using fields, variable-backed properties, or Dependency Properties Dependency Properties: Used to support data binding Required for property promotion State is stored in a dictionary Used by the runtime to: Serialize and manage state Intercept the state changes made during execution

52 Building Activities

53 Activity Execution Status Returned by Execute() method Can be determined by a parent activity or workflow Activity.ExecutionStatus Tracked by a Tracking Runtime Service ActivityExecutionStatus Enumeration Initialized Executing Compensating Cancelling Closed Faulting

54 Activity Execution Activity Execution Methods Initialize() Execute() Cancel() Compensate() HandleFault() Transition Types Activity Runtime Initialized Executing Closed Canceled Compensating Faulted

55 Building Long-Running Activities

56 Activity Summary An Activity is a key concept of Windows Workflow Foundation WF allows you to write custom activities to model your application control flow explicitly Activities are the fundamental unit of: Execution, Reuse, & Composition Two broad types of activities: Basic & Composite Activity Designer simplifies the development of custom activities – especially composites System.Workflow.ComponentModel provides the framework to build custom activities Call to action: Write Activities!

57 Runtime Services The workflow runtime is lightweight Depends on a set of services Often you also want Transactions and Persistence Add services programmatically or using a config file What ships in System.Workflow.Runtime.Hosting? Concrete service implementations DefaultWorkflowSchedulerService (asynchronous) ManualWorkflowSchedulerService (synchronous; for ASP.NET scenarios) DefaultWorkflowTransactionService SqlWorkflowPersistenceService

58 Runtime Services Host Application App Domain SQL Out of Box Services are provided that support SQL Server 2000 & 2005 Common resource services for managing threading, timers and creating transactions PersistenceService stores and retrieves instance state. TrackingService manages profiles and stores tracked information. WF Runtime Services PersistenceService TrackingService SchedulerService TransactionService

59 Out-of-Box Services ManualWorkflowSchedulerS ervice Synchronous threading service used for in-line execution; used by ASP module for web services DefaultWorkflowSchedulerS ervice Used for asynchronous execution of workflows; uses default.Net thread pool DefaultWorkflowTransaction Service Creates.NET transactions SharedConnectionWorkflow Trans-actionService Sql* services share connection to SqlServer SqlStatePersistenceServiceStores workflow instance state information in SqlServer/MSDE SqlTrackingServiceStores tracking information in SqlServer/MSDE

60 Workflow State Management Many workflows are long running A workflow instance is idle when it has no runnable work Persistence services determine whether to unload the WF when idle Loading/unloading is not a concern of the workflow developer or the application developer Persistence points are checkpoints Transactions Enable crash recovery Persistence occurs at: Closure of a transaction Closure of any activity marked [PersistOnClose] Closure of the workflow

61 Enabling Workflow Persistence Persistence Support for Workflow Instances Create the SQL database with the SqlWorkflowStatePersistence schema Create a Workflow Runtime Define Connection String Register StatePersistenceService with Runtime Start the Workflow Loading and Unloading uses StatePersistenceService private void RunWorkflow() { WorkflowRuntime wr = new WorkflowRuntime(); string connectionstring = "Initial Catalog=Persistence;Data Source=localhost;Integrated Security=SSPI;"; wr.AddService(new SqlWorkflowStatePersistenceService(connectionstring)); wr.CreateWorkflow(typeof(SimpleWorkflow)).Start(); }

62 Building Custom Services

63 Hosting the Workflow Designer

64 Summary A single workflow technology for Windows Platform level workflow framework for use within Microsoft products & ISV applications Will be used by BizTalk Server, Office 2007, MBS & other Microsoft client/server products Available to all Windows customers Microsoft is redefining workflow Unified technology for System & Human workflow Multiple styles: sequential, rules-based, state machine Supports dynamic interaction Microsoft is taking workflow mainstream Consistent and familiar programming model for reaching mainstream application developer Available to millions of end-users through Office 2007 Extensible platform for ISVs

65 Community Site Subscribe to the RSS feed for news & updates Find, download, & register Activities Find blogs, screencasts, whitepapers, and other resources Download samples, tools, and runtime service components http://wf.netfx3.com MSDN® Workflow Page Download 12 Hands-on Labs http://msdn.microsoft.com/workflow Forums Ask questions in the forums Go to the community site Windows Workflow Foundation Resources

66


Download ppt "Windows Server 2008 – Windows Communication Foundation Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK."

Similar presentations


Ads by Google