1 / 66

Windows Server 2008 – Windows Communication Foundation

Windows Server 2008 – Windows Communication Foundation. Dave Allen ISV Application Architect Developer and Platform Group Microsoft UK. Agenda. WCF Architecture Contracts Bindings Address Behaviours Windows Process Activation Service Hosting WF from WCF in IIS 7.0. A. A. A. B. B.

katelin
Télécharger la présentation

Windows Server 2008 – Windows Communication Foundation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Agenda • WCF Architecture • Contracts • Bindings • Address • Behaviours • Windows Process Activation Service • Hosting WF from WCF in IIS 7.0

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

  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. Service Contract [ServiceContract] public interface IHello { [OperationContract] string Hello(string name); } public classHelloService : IHello { public string Hello(string name) { return “Hello ” + name; } }

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

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

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

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

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

  11. Binding HTTP Security RM TX Text Bindings Transport Encoders Protocol TCP HTTP Text WS-* Binary MSMQ Pipes MTOM Custom Custom Custom

  12. Standard Bindings T = Transport Security | S = WS-Security | O = One-Way Only

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

  14. Choosing Bindings • 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

  15. Addresses http://microsoft.com:80/OrderService/WS https://microsoft.com:443/OrderService/BP net.tcp://microsoft.com:808/OrderService/TCP net.pipe://microsoft.com/OrderService/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 scalablehost 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. Service Hosting Self-host class HelloHost { static void Main(string[] args) { ServiceHosthost = new ServiceHost(typeof(HelloService)); host.Open(); // Wait until done accepting connections Console.ReadLine(); host.Close(); } } IIS-host http://localhost/HelloService/HelloService.svc <%@ServiceHost language=c# Service=“HelloService" %>

  18. Service Configuration <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <services> <service name=“HelloService”> <endpoint address=“” binding=“basicHttpBinding" contract="IHello" /> </service> </services> </system.serviceModel> </configuration>

  19. demo Windows Communication Foundation

  20. Behaviours • Behaviours cover the system semantics • Service features • Concurrency • Instancing • Transactions • Impersonation • Deployment features • Throttling • Metadata exposure

  21. Instancing • Per Call • Single • Private Session • Shared Session

  22. Concurrency • Multiple • Reentrant • Single

  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 Address Binding Contract Behavior Request/Response InstancingBehavior HTTPTransport WS-SecurityProtocol ConcurrencyBehavior http://... Peer Transport net.p2p://... Throttling Behavior WS-RMProtocol TCP Transport net.tcp://... MetadataBehavior NamedPipeTransport WS-CoordProtocol One-Way net.pipe://... Error Behavior TransactionBehavior MSMQTransport DuplexChannel net.msmq://... CustomBehavior SecurityBehavior Duplex CustomTransport CustomProtocol xxx://... 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 • WCF community site http://wcf.netfx3.com/ • Great WAS article for developers http://msdn.microsoft.com/msdnmag/issues/07/09/WAS/

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

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

  36. Windows Workflow Foundation Windows Workflow Foundation is the programming model, engine and tools for quickly building workflow enabled applications on Windows. • 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

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

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

  39. Building a Workflow

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

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

  42. Order Processing Example On Order Completed On Order Processed On Order Created Waiting to Create Order Order Created Order Processed On Order Completed On Order Shipped On Order Shipped Order Shipped Order Completed On Order Completed

  43. A State Machine Workflow

  44. 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

  45. 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

  46. Domain-SpecificWorkflow Packages Compliance CRM Extend activity Compose activities RosettaNet Author new activity IT Mgmt • Vertical-specificactivities & workflows • Best-practice IP &Knowledge Activities: An Extensible Approach Custom ActivityLibraries Base Activity Library Out-of-Box Activities • OOB activities,workflow types,base types • General-purpose • Activity libraries define workflow constructs • Create/Extend/Compose activities • App-specificbuilding blocks • First-class citizens

  47. 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 Workflow Execution Logic Simplicity Code Activity InvokeWebService Activity InvokeMethod & EventSink Custom Activities Flexibility

  48. 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"; } }

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

More Related