46
Messaging Messaging with Web Services with Web Services Enhancements 2.0 Enhancements 2.0 Benjamin Mitchell Benjamin Mitchell Independent Consultant Independent Consultant Microsoft Regional Director Microsoft Regional Director – UK – UK Blog Blog http://benjaminm.net/ http://benjaminm.net/ [email protected] [email protected]

Messaging with Web Services Enhancements 2.0

  • Upload
    gaetan

  • View
    37

  • Download
    5

Embed Size (px)

DESCRIPTION

Messaging with Web Services Enhancements 2.0. Benjamin Mitchell Independent Consultant Microsoft Regional Director – UK Blog http://benjaminm.net/ [email protected]. What We Will Cover:. Overview of Web Services Enhancements 2.0 What problems does Messaging solve? - PowerPoint PPT Presentation

Citation preview

Page 1: Messaging  with Web Services Enhancements 2.0

Messaging Messaging with Web Services with Web Services Enhancements 2.0Enhancements 2.0

Benjamin MitchellBenjamin MitchellIndependent ConsultantIndependent ConsultantMicrosoft Regional Director – UKMicrosoft Regional Director – UKBlog Blog http://benjaminm.net/http://benjaminm.net/[email protected]@benjaminm.net

Page 2: Messaging  with Web Services Enhancements 2.0

What We Will Cover:What We Will Cover:

Overview of Web Services Overview of Web Services Enhancements 2.0Enhancements 2.0

What problems does Messaging solve?What problems does Messaging solve?

Why does Messaging solve them?Why does Messaging solve them?

What types of Messaging models are What types of Messaging models are there?there?

How can I use these programming How can I use these programming models today?models today?

Page 3: Messaging  with Web Services Enhancements 2.0

Web Services EnhancementsWeb Services Enhancements

WSE implements many WS-* WSE implements many WS-* specificationsspecifications

Simple, low-level object model for Simple, low-level object model for developers developers

Available for free downloadAvailable for free download

Logically part of the .NET Framework, Logically part of the .NET Framework, but kept separate while still evolving but kept separate while still evolving

Fully supported by Microsoft until at Fully supported by Microsoft until at least 2008least 2008

Version 1.0 Dec 2002, Version 2.0 May 2004Version 1.0 Dec 2002, Version 2.0 May 2004

Version 2.0 SP 2 pre-release available nowVersion 2.0 SP 2 pre-release available now

BenefitsBenefitsAllows MS to gather real world feedbackAllows MS to gather real world feedback

Allows early adopters to use the latest Allows early adopters to use the latest standardsstandards

Page 4: Messaging  with Web Services Enhancements 2.0

WSE 2.0WSE 2.0

Designed to bring advanced Web Services Designed to bring advanced Web Services technologies based on standard protocols to technologies based on standard protocols to developersdevelopers

Integrates with Visual Studio .NET and .NET Integrates with Visual Studio .NET and .NET FrameworkFramework

What do you get with WSE?What do you get with WSE?WS-AddressingWS-Addressing

WS-SecurityWS-Security

WS-PolicyWS-Policy

WS-SecurityPolicyWS-SecurityPolicy

WS-TrustWS-Trust

WS-SecureConversationWS-SecureConversation

WS-ReferralWS-Referral

WS-AttachmentsWS-Attachments

InteroperabilityInteroperability

Page 5: Messaging  with Web Services Enhancements 2.0

User Code

How does WSE work?How does WSE work?

SoapContext

Tra

ce

Secu

rity

Refe

rral

Policy

Custo

m

Security Token

Manager

Custom Filters

Page 6: Messaging  with Web Services Enhancements 2.0

Problem StatementProblem Statement

Issues with connected systemsIssues with connected systemsBandwidth and LatencyBandwidth and LatencyDomain boundariesDomain boundariesCoordination and ManagementCoordination and Management

SolutionSolutionLess transparencyLess transparencyMore ExplicitnessMore Explicitness

ImplementationImplementationMessage-based programming modelsMessage-based programming models

Page 7: Messaging  with Web Services Enhancements 2.0

TransparencyTransparency

Transparent programming models Transparent programming models are easyare easy

But, they obscure:But, they obscure:Location of code executionLocation of code execution

Complete context of executionComplete context of execution

You don’t know that you don’t knowYou don’t know that you don’t know

Page 8: Messaging  with Web Services Enhancements 2.0

ExplicitnessExplicitness

Explicit programming models Explicit programming models leave more for the developer to leave more for the developer to dodo

They do not obscure as much:They do not obscure as much:Network activity is apparentNetwork activity is apparent

Context and timing is knownContext and timing is known

You know you don’t know so you You know you don’t know so you take precautionstake precautions

Enables communication to offline Enables communication to offline services services

Page 9: Messaging  with Web Services Enhancements 2.0

About MessagingAbout Messaging

Several programming models within Several programming models within the "messaging" bucketthe "messaging" bucket

Eventing (often called Pub/Sub)Eventing (often called Pub/Sub)DialogsDialogsQueuesQueuesRequest-ResponseRequest-Response

Key benefitsKey benefitsMore natural fit for many business processesMore natural fit for many business processesAllows for more asynchronous processingAllows for more asynchronous processing

Many configurationsMany configurations"Smart" routers"Smart" routersOffline machinesOffline machinesEtc…Etc…

Page 10: Messaging  with Web Services Enhancements 2.0

Web Services and MessagingWeb Services and Messaging

A way of exposing functionality A way of exposing functionality using a set of interoperable using a set of interoperable protocolsprotocols

Messages exchanged based on a Messages exchanged based on a shared schemashared schema

Independent of the programming Independent of the programming language used language used

No shared classesNo shared classesUnless you intentionally share Unless you intentionally share themthem

Page 11: Messaging  with Web Services Enhancements 2.0

Messaging Implementations Messaging Implementations

MSMQMSMQClassicClassic

Offline QueuingOffline Queuing

ASMXASMXEasy to useEasy to use

WSE V2WSE V2Transport IndependenceTransport Independence

Host anywhereHost anywhere

Page 12: Messaging  with Web Services Enhancements 2.0

MSMQ MessagingMSMQ Messaging

The classic messaging APIThe classic messaging API

MessageQueue classMessageQueue class

Two important methodsTwo important methodsSendSend

ReceiveReceive

Can provide reliable, in order, only Can provide reliable, in order, only once delivery as well as transaction once delivery as well as transaction supportsupport

Requires MSMQ at both ends of the Requires MSMQ at both ends of the pipelinepipeline

Page 13: Messaging  with Web Services Enhancements 2.0

ASMX MessagingASMX Messaging

Easiest way to message with Easiest way to message with SOAPSOAP

Create an *.asmx fileCreate an *.asmx file

Write a classWrite a class

Decorate methods with Decorate methods with [WebMethod][WebMethod]

OneWay or RequestResponseOneWay or RequestResponse

Page 14: Messaging  with Web Services Enhancements 2.0

WSE 2.0 MessagingWSE 2.0 Messaging

WSE 2.0 includes a SOAP-based WSE 2.0 includes a SOAP-based messaging APImessaging APITransport independenceTransport independence

Intra-AppDomainIntra-AppDomainFor testingFor testing

Raw TCPRaw TCPHTTPHTTP

Host IndependenceHost IndependenceWindows applicationWindows applicationASP.NETASP.NETWindows ServiceWindows Service

Page 15: Messaging  with Web Services Enhancements 2.0

WSE 2.0 MessagingWSE 2.0 Messaging

SoapSender and SoapReceiverSoapSender and SoapReceiverOne way messagesOne way messages

Deal with the SoapEnvelope rather than Deal with the SoapEnvelope rather than method parametersmethod parameters

Must implement method dispatching Must implement method dispatching based on based on SoapEnvelope.Context.Adressing.ActionSoapEnvelope.Context.Adressing.Action

No automated reply messagesNo automated reply messagesThe Receiver must implement a new SenderThe Receiver must implement a new Sender

Sender must indicate reply addressSender must indicate reply address

Page 16: Messaging  with Web Services Enhancements 2.0

Demonstration 1Demonstration 1

SoapSender and SoapReceiverSoapSender and SoapReceiver

Page 17: Messaging  with Web Services Enhancements 2.0

WSE 2.0 Messaging WSE 2.0 Messaging (Continued)(Continued)

SoapClient and SoapServiceSoapClient and SoapServiceOne-way and two-wayOne-way and two-way

Uses SoapSender/SoapReceiverUses SoapSender/SoapReceiver

Offers XML Serialization support Offers XML Serialization support

Operation-based dispatchingOperation-based dispatchingThe Action is used to deliver the message to a The Action is used to deliver the message to a MethodMethod

Automatic replyingAutomatic replying

Page 18: Messaging  with Web Services Enhancements 2.0

Demonstration 2Demonstration 2

SoapClient and SoapServerSoapClient and SoapServer

Page 19: Messaging  with Web Services Enhancements 2.0

WSE 2.0 Messaging WSE 2.0 Messaging (Continued)(Continued)

ChannelsChannelsQueued modelQueued model

Raw, explicit programmingRaw, explicit programming

Page 20: Messaging  with Web Services Enhancements 2.0

Programming Models Programming Models

ReceivingReceivingPollingPolling

PushPush

AdaptationAdaptationAdapterAdapter

MapperMapper

ErrorsErrorsDead letter Dead letter channelchannel

FaultsFaults

GatewayGatewayAggregating Aggregating GatewayGateway

RouterRouter

Page 21: Messaging  with Web Services Enhancements 2.0

Programming Models: Programming Models: ReceivingReceiving

Push-modelPush-model

Implicit message receiveImplicit message receive

Message is processed when message Message is processed when message arrivesarrives

Allows for ActivationAllows for Activation

CLIENTCLIENT

Page 22: Messaging  with Web Services Enhancements 2.0

Demonstration 3Demonstration 3

Push-model messaging with Push-model messaging with ASMXASMX

Page 23: Messaging  with Web Services Enhancements 2.0

Programming Models: Programming Models: ReceivingReceiving

Polling to receive messagesPolling to receive messages

Explicit message receiveExplicit message receive

Lets recipient control when message Lets recipient control when message is processedis processed

CLIENTCLIENT

Page 24: Messaging  with Web Services Enhancements 2.0

Demonstration 4Demonstration 4

Message Polling with WSE 2.0Message Polling with WSE 2.0

Page 25: Messaging  with Web Services Enhancements 2.0

Programming Models: Programming Models: AdaptationAdaptation

Application not always messaging Application not always messaging awareaware

Too costly to re-code entire appToo costly to re-code entire app

Adapters translate app-specific data Adapters translate app-specific data and behavior into Messagesand behavior into Messages

APPLICATIAPPLICATIONON

ADAPTERADAPTER

Page 26: Messaging  with Web Services Enhancements 2.0

Message on wire is serialized into Message on wire is serialized into common formatcommon format

Message data on system not always Message data on system not always serializableserializable

Message mapper deals with thisMessage mapper deals with this

MAPPERMAPPER

Programming Models: Programming Models: AdaptationAdaptationProgramming Models: Programming Models: AdaptationAdaptation

DATADATA MESSAGEMESSAGE

Page 27: Messaging  with Web Services Enhancements 2.0

Programming Models - ErrorsProgramming Models - Errors

Two errors messaging is well-suited Two errors messaging is well-suited to deal withto deal with

Dead lettersDead letters

Invalid messagesInvalid messages

ExceptionsExceptionsExceptions can occur before dispatchExceptions can occur before dispatch

In user codeIn user code

Soap Faults map to ExceptionsSoap Faults map to ExceptionsFault codes are QNamesFault codes are QNames

Page 28: Messaging  with Web Services Enhancements 2.0

Design: GatewayDesign: Gateway

Wraps application-specific logicWraps application-specific logic

Most Web services are gatewaysMost Web services are gateways

GATEWAYGATEWAY APP APP CODECODE

Page 29: Messaging  with Web Services Enhancements 2.0

Design: GatewayDesign: Gateway

Aggregator is gateway that combines Aggregator is gateway that combines several messages into one internal several messages into one internal actionaction

GATEWAYGATEWAY APP APP CODECODE

Page 30: Messaging  with Web Services Enhancements 2.0

Design: RouterDesign: Router

Routes a message from a source to a Routes a message from a source to a destinationdestination

ROUTERROUTERSOURCESOURCE DESTINATIDESTINATIONON

Page 31: Messaging  with Web Services Enhancements 2.0

Design: RouterDesign: Router

Several type of routersSeveral type of routersSplittersSplitters

AggregatorsAggregators

FiltersFilters

ROUTERROUTER

ROUTERROUTER

ROUTERROUTERABABCC

ABZABZ

Page 32: Messaging  with Web Services Enhancements 2.0

Design: RouterDesign: Router

And content-based routersAnd content-based routers

AAROUTERROUTER

BB

ABABCC =

AB

=A

BCC

=DE=DEFF

Page 33: Messaging  with Web Services Enhancements 2.0

Design: Pub/SubDesign: Pub/Sub

Publication and SubscriptionPublication and Subscription

Message patternMessage patternOne message to subscribeOne message to subscribe

One to many messages publishing event One to many messages publishing event informationinformation

Observer pattern over a Observer pattern over a distributed systemdistributed system

Page 34: Messaging  with Web Services Enhancements 2.0

Design: Pub/SubDesign: Pub/Sub

More on pub/subMore on pub/sub

EVENT EVENT SERVICESERVICE

SUBSCRIBSUBSCRIBERER

SUBSCRISUBSCRIBEBE

EVENTSEVENTS

Page 35: Messaging  with Web Services Enhancements 2.0

Design: Pub/SubDesign: Pub/Sub

Two models for getting event Two models for getting event datadata

Push – notification includes dataPush – notification includes data

Pull – subscriber sends a request for the Pull – subscriber sends a request for the subscription data after receiving the subscription data after receiving the eventevent

Push is usually best for Web Push is usually best for Web servicesservices

Pull is good when subscribers Pull is good when subscribers may not be interested in the data may not be interested in the data and the data is large or processor and the data is large or processor intensiveintensive

Page 36: Messaging  with Web Services Enhancements 2.0

Demonstration 5Demonstration 5

EventingEventing

Page 37: Messaging  with Web Services Enhancements 2.0

Design: ReliabilityDesign: Reliability

Strongest and most resilient Strongest and most resilient systems implement reliable systems implement reliable messagingmessaging

Reliable messaging requires:Reliable messaging requires:Idempotent processingIdempotent processing

Durable storageDurable storage

NODENODE NODENODE

Page 38: Messaging  with Web Services Enhancements 2.0

Design: Dialogs and QueuesDesign: Dialogs and Queues

Dialogs are virtual connections Dialogs are virtual connections between two nodesbetween two nodes

With the help of queues, dialogs can With the help of queues, dialogs can be reliable and persistent across be reliable and persistent across system resetssystem resets

Page 39: Messaging  with Web Services Enhancements 2.0

NODENODE

Design: Dialogs and QueuesDesign: Dialogs and Queues

More on dialogs and queuesMore on dialogs and queues

NODENODE

Page 40: Messaging  with Web Services Enhancements 2.0

Design: Long-Running Design: Long-Running OperationsOperations

Long-running operationsLong-running operationsA key gain of messagingA key gain of messaging

Allows closer modeling of real-life Allows closer modeling of real-life business scenarios business scenarios

ExamplesExamplesUser interaction is neededUser interaction is needed

Batch processing across multiple nodesBatch processing across multiple nodes

Page 41: Messaging  with Web Services Enhancements 2.0

Design: Long-Running Design: Long-Running OperationsOperations

ExampleExample

NODENODE NODENODE

NODENODE

NODENODE

NODENODE

Page 42: Messaging  with Web Services Enhancements 2.0

Design GuidelinesDesign Guidelines

Avoid RPC and CRUD designsAvoid RPC and CRUD designsTends to encourage RPC like behaviorTends to encourage RPC like behavior

Interface may imply stateful interactions Interface may imply stateful interactions like enumerationlike enumeration

Interface is likely to be overly chattyInterface is likely to be overly chatty

Don’t be too loose or extensibleDon’t be too loose or extensibleFocus on encapsulating business Focus on encapsulating business processesprocesses

Use contracts to reduce couplingUse contracts to reduce coupling

Page 43: Messaging  with Web Services Enhancements 2.0

Session SummarySession Summary

Messaging allows for apps that more Messaging allows for apps that more closely match business processesclosely match business processes

Applications that use messaging are Applications that use messaging are more closely matched with business more closely matched with business processesprocesses

Existing technology can be used to Existing technology can be used to support messagingsupport messaging

WSE 2.0 provides extensible messaging WSE 2.0 provides extensible messaging with web services across multiple with web services across multiple protocolsprotocols

Page 44: Messaging  with Web Services Enhancements 2.0

Call to ActionCall to Action

Start designing with messaging in mindStart designing with messaging in mind

Download WSE 2.0 Service Pack 1Download WSE 2.0 Service Pack 1

Download the Hands-On Labs on WSE Download the Hands-On Labs on WSE Messaging from Aaron SkonnardMessaging from Aaron Skonnard

http://http://msdn.microsoft.com/webservices/buildimsdn.microsoft.com/webservices/building/wse/default.aspxng/wse/default.aspx

Page 45: Messaging  with Web Services Enhancements 2.0

For More InformationFor More Information

BlogsBlogshttp://benjaminm.nethttp://benjaminm.net

Rebecca Dias WSE Product ManagerRebecca Dias WSE Product Managerhttp://weblogs.asp.net/rdiashttp://weblogs.asp.net/rdias

Hervey Wilson Lead Developer WSE Hervey Wilson Lead Developer WSE http://dynamic-cast.comhttp://dynamic-cast.com

NewsgroupNewsgroupmicrosoft.public.dotnet.framework.webservices.enhancememicrosoft.public.dotnet.framework.webservices.enhancementsnts

BooksBooksEnterprise Integration PatternsEnterprise Integration Patterns – Gregor – Gregor Hohpe and Bobby WoolfHohpe and Bobby Woolf

Page 46: Messaging  with Web Services Enhancements 2.0