41
Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. www.reliablesoftware.com Pre-requisites for this presentation: 1) Understand WCF 2) Understand WFC Level: Intermediate

Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Software + Services Using WCF and WF

Michael StiefelReliable Software, Inc.

www.reliablesoftware.com

Pre-requisites for this presentation:

1) Understand WCF2) Understand WFC

Level: Intermediate

Page 2: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Understand Software + Services

Understand WF and WCF Integration

Goals

Page 3: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Where Does Computation Happen?

Page 4: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Everywhere

Page 5: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Why?

Page 6: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Hardware Is Cheap

Data Is Expensive To Move

Page 7: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Compute Where Data Naturally Lives

Page 8: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Software + Services

“World of small pieces loosely joined”

Ray Ozzie, Chief Software Architect, MicrosoftMIX Keynote

Page 9: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Service Oriented ArchitectureService Composition

Web 2.0Network Effect

Software as a ServiceService Delivery

Rich Internet ApplicationsExperience

Software + Services

Cloud ComputingService Utility

Computing Ecosystem

Page 10: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Architectural Layers

Client SoftwareApplication ServicesInfrastructure ServicesFoundation Services

Page 11: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Client Software

BrowsersMobilePersonal Computers (On/Offline)Embedded DevicesSpeech

Page 12: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Application Services

Web Presentation ServicesStatic, Dynamic, Rich, Streaming

MonetizationTransaction, Subscription, Advertising

Programmatic ServicesWeb Services, REST, Voice, SMS, SMTP

CollaborationSearch, Social, Content

Business IntelligenceDashboard, Reporting

Workflow, Schemas, Rules

Page 13: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Infrastructure Services

SecurityUsername / Password, Claims, Roles

MessagingService Bus, Peer to Peer

StorageFiles, Relational, Unstructured (Key Value Pairs)

Workflow EngineTriggered by EventsCoordinated Flows

Page 14: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Foundation Services

Physical DedicatedPhysical SharedVirtualized SingleVirtualized SharedClusters

Vendor HostedSelf Hosted

Page 15: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Simple Web Site

Client SoftwareBrowser

Application ServicesStatic HTML, Business Logic

Infrastructure ServicesFile Storage

Foundation ServicesPhysical, Shared Server

Page 16: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Software as a Service

Client SoftwareBrowser

Application ServicesStatic HTML, Web Services, Business Logic, Workflows

Infrastructure ServicesRelational Database

Foundation ServicesVendor Hosted, Virtualized, Dedicated Servers

Page 17: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Business Logic and Workflows Imply Long Running Business Processes

Business Processes Exposed As Services

Page 18: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

How do you expose long running business processes as services?

Page 19: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

WCF and WF Integration Encapsulates Long Running Business Services

Page 20: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

What is Different in .NET 3.5?

Possible in Framework 3.0

Declarative Model in Framework 3.5

Basis for future integration

Page 21: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

New Framework 3.5 Features

Send and Receive Activities

New WCF Context Bindings

New WCF Projects and Templates

System.WorkflowServices assembly

Page 22: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Key Concepts

Workflow setup inside WCF Host

Send messages to right workflow instance

Page 23: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Key Technical Concepts

WCF Extensibility Points

Workflow Context flows with service call

Page 24: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

WCF Extensibility Points

Extend or modify WCF runtimeExtensibility Points:

Service HostService ModelBindingsChannelsSecurityMetadataEncoders and Serializers

Page 25: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

ContextBindingElement

Create context aware bindings:WsHttpContextBindingBasicHttpContextBindingNetTcpContextBinding

Extends binding to allow context flow

Context in SOAP header or HTTP cookie

Page 26: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

WF and WCF Dependencies

Workflow uses WCF Extensibility and ContextBindingElement.

WCF knows nothing about Workflow.

Page 27: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Workflow Context

Workflow Instance Id

Correlation to correct instance of a service

Page 28: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Steps

Define Service Interfaces

Add Workflow

Write the Host

Endpoints and Behaviors to App.Config

Page 29: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Context Demo

Receive Activity and Non-WF Client

Page 30: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Simple Activity Demo

Send and Receive Activities

Page 31: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Receive Activity

Processes a service call:ServiceOperationInfoContextTokenCanCreateInstanceDatabinding to Parameters and Return ValueFault Message

Sequential Composite Activity

Page 32: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

ServiceOperationInfo Demo

Contract First Design

Workflow First DesignInterface defined inside of workflow type

Page 33: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Receive Activity “Magic”

No Local Services to map services to Workflow Events

No correlations for parallel service waits

Infrastructure builds appropriate workflow queues and correlations

Page 34: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Send Activity

Make a service request:ServiceOperationInfo

ChannelToken

CustomAddress

Associate context with activity

ChannelTokens with same name, owner cached

Page 35: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

WorkflowServiceHost

Derives from ServiceHostBase

WorkflowRuntimeBehaviorGet WorkflowRuntime instance through

WorkflowRuntimeBehavior

No IExtension<ServiceHostBase>

Page 36: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Context Flow Demo

Coordinated context flow between send and receive activities in separate workflows

Page 37: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Workflow Conversations Demo

Context can distinguish among workflow branches

Page 38: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Multiple Service Hosts

One WindowsServiceHost per workflow

One WorkflowRuntime for each workflow

Contention??SqlPersistenceService

Page 39: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Extended Example Demo

Page 40: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

IIS Hosting

WorkflowServiceHostFactoryService definition can be a XAML file or type

<%@ServiceHost Language=“C#” Service=“foo.xoml” Factory=“System.ServiceModel.Activation.WorkflowServiceHostFactory” %>

Page 41: Software + Services Using WCF and WF · Software + Services Using WCF and WF Michael Stiefel Reliable Software, Inc. . Pre-requisites for this presentation: 1) Understand WCF

Summary

WCF and WF Integration Much Easier

Extends Declarative Model

Service Encapsulation of Long Running Business Processes