soa visão geral das funcionalidades de descoberta e roteamento de serviços em wcf 4
Post on 11-Jan-2016
219 Views
Preview:
TRANSCRIPT
SOA
Visão Geral das Funcionalidades de
Descoberta e Roteamento de Serviços em WCF 4
www.rumos.pt
jorge.goncalves@rumos.pt
• (MCT) Microsoft
Certified Trainer
• (MCPD) ASP.NET
Developer 3.5
• (MCTS) Microsoft Office
SharePoint Server 2007
– Configuration
• Formador Rumos
• Sys Admin DGITA
• Consultor
• Analista Programador
• PG GSI
• PG Informática
• LIC Informática
DEMOS
Demo : Creating a Calculator Service
Demo : Service Routing
Demo : Add-hoc Service Discovery Demo : Managed Service Discovery
Comunidade Rumos – Webcasts http://comunidade.rumos.pt/webcasts.rumos
Source Code: MSDN (WCF) Sampleshttp://msdn.microsoft.com/en-us/library/dd483346.aspx
Why SOA?
• Challenges in Building Business Applications
• Objectives of Service-Oriented Architecture
• What Is a Service?
• The Pillars of SOA
• Services Communicate Through Edges
Challenges in Building Business Applications
We are living in a distributed world
Business is agile
Efficient integration and interoperability are essential
Costs must be reduced
Systems have to be scalable, secure, and reliable
Objectives of Service-Oriented Architecture
SOA is an architectural style designed for building distributed systems
Agility
Reuse Reduce Cost
Productivity
What Is a Service?
A service exposes functionality by accepting data (requests) and sometimes returning data (responses)
The Pillars of SOA
Services handle data, not objects
Services are autonomous
Services have explicit boundaries
Services expose contract and policy
The following properties define a service-oriented architecture:
Services Communicate Through Edges
Services expose edges to the outside world—edges can be used for communication with the service
All interaction with a service is done through an edge
A service can expose multiple edges
The edge has an address
SOA edges are WCF endpoints
Demo Creating a Calculator Service
- The Service- ServiceHost Class- Endpoint ABC (address binding contract)- Metadata behaviour- Endpoint behaviour
- The Client- Proxy Pattern
Routing
• The Benefits of Routing• Introduction to the WCF Routing Service• Configuring Routing Using Message Filters• Configuring Routing Endpoints and Filters• Using Custom Filter Types and Content-Based
Routing• Using Routers for Protocol Bridging• Using Routers to Mask Service Unavailability• Using Routers for Multicast Messaging
The Benefits of Routing
The broker design pattern provides agility and reliability to distributed systems, and enables:
Content-based load balancing
Automatically use of fallback services
Protocol bridging
Masking of versioning issues
Introduction to the WCF Routing Service
The Routing Service is part of WCF 4, and is implemented in the System.ServiceModel.Routing.RoutingService class
Hosted like any other service
Supports all messaging patterns
Determines the target service by evaluating each incoming message against a set of message filters
Implements the ISimplexDatagramRouter, ISimplexSessionRouter, IRequestReplyRouter, and IDuplexSessionRouter contracts
Configuring Routing Using Message Filters
Message filters are specified in code or in the Routing configuration section
Message filters are grouped into filter tables
The routing configuration contains filter types and a collection of mappings between a message filter and a target endpoint
The RoutingBehavior defines the filter table to use
Configuring Routing Endpoints and Filters
<routing> <filters> <filter name="MatchAllFilter" filterType="MatchAll"/> </filters> <filterTables> <filterTable name="MyFilterTable"> <add filterName="MatchAllFilter" endpointName="Service"/> </filterTable> </filterTables></routing><behaviors> <serviceBehaviors> <behavior name="UseRouting"> <routing filterTableName="MyFilterTable" /> </behavior> </serviceBehaviors></behaviors><client> <endpoint name="Service“ address="..." binding="...“ contract="..."/> </client>
Using Custom Filter Types and Content-Based Routing
WCF supports a wide range of filter types
You can use XPath filters to inspect the content of the incoming messages
You can define custom filters (rules) that target messages according to their content
You can create custom filter types for advanced routing scenarios
Using Routers for Protocol Bridging
The client-to-router and router-to-service bindings do not have to match
You can bridge incompatible protocols using a Routing Service as the middle-man
The client-to-router and router-to-service messaging patterns must match
Using Routers to Mask Service Unavailability
You can configure the router service to route a message to a backup service if the target service fails; this masks service unavailability and improves reliability
<routing><filters> <filter name="MatchAllFilter" filterType="MatchAll"/></filters><filterTables> <filterTable name="MyFilterTable"> <add filterName="MatchAllFilter" endpointName="CalcService" backupList="AlternateCalc"/> </filterTable></filterTables><backupLists> <backupList> <add endpointName="AlternateCalc"/> </backupList> </backupLists></routing>
Using Routers for Multicast Messaging
The Routing Service supports multicast, enabling publish/subscribe and distribution-style messaging
If the incoming message matches multiple filters, it will be delivered to each of the target endpoints
Multicast only works for one-way or duplex messaging; it does not work for request-response messaging
WCF Discovery
• Introduction to WCF Discovery• Ad-Hoc Discovery Architecture• The Process of Ad-Hoc Discovery• Configuring Ad-Hoc Discovery• Issuing Probe and Resolve Messages
• Discovery Proxy Architecture• The Process of the Discovery Proxy• Discovering Services Using a Discovery Proxy
Discovery addresses the question: Where is the service?
The service’s location is dynamic
Discovery and Service Repository using WS-Discovery
Discovery enables agility – choose the service to consume at runtime
Introduction to WCF Discovery
Ad-Hoc Discovery Architecture
WCF 4 introduces WS-Discovery support that consists of two message categories:
Announcements (Hello/Bye messages)
Discovery (Probe/Resolve messages)
The Process of Ad-Hoc Discovery
Hello
Bye
Probe
Resolve
Service is up
Service is up
Service is downService is down
Where is the
service?
Where is the
service?
Discovery
Announcement
CLI
EN
T
Configuring Ad-Hoc Discovery
<behavior name="SendAnnouncements"> <serviceDiscovery> <!--specify that announcement messages will be sent and where.--> <announcementEndpoints> <endpoint kind="udpAnnouncementEndpoint"/> </announcementEndpoints> </serviceDiscovery> </behavior>
<standardEndpoints> <udpDiscoveryEndpoint> <!--Specify the discovery protocol version and maxResponseDelay--> <standardEndpoint name="adhocDiscoveryEndpointConfiguration“
discoveryVersion="WSDiscovery11" maxResponseDelay="00:00:00.600" />
</udpDiscoveryEndpoint> </standardEndpoints>
<service name=“...” behaviorConfiguration="SendAnnouncements"> . . . <!-- listen for discovery request messages. --> <endpoint name="udpDiscovery" kind="udpDiscoveryEndpoint“ endpointConfiguration="adhocDiscoveryEndpointConfiguration"/> </service>
Issuing Probe and Resolve Messages
The DynamicEndpoint class is used by the client to issue probe messages
Dynamic endpoints can be defined in code and in the XML configuration file
The FindCriteria class enables granular discovery
// Discover endpoints when the client is opened. // The contract is used as the FindCriteria.// UdpDiscoveryEndpoint is used to send Probe message.DynamicEndpoint dynamicEndpoint = new DynamicEndpoint( ContractDescription.GetContract(
typeof(ICalculatorService)), new WSHttpBinding());
DemoAdd-hoc Service Discovery
- The Service- behaviourConfiguration for serviceDiscovery
- announcementEndpoints for announcements
- Enpoint with kind=“udpDiscoveryEndpoint” for discovery- Calc endpointBehaviorConfiguration behaviour for scope criteria
- The Client- Endpoint with kind=“dynamicEndpoint” and
dynamicEndpointConfiguration for find scope criteria
Discovery Proxy Architecture
The discovery proxy enables discovery support outside the enterprise:
Listens for announcements and caches endpoint information internally
Forwards “Probe” and “Resolve” messages
Can function as a router
The Process of the Discovery Proxy
Hello
Bye
Probe
Resolve
Service is up
Service is up
Service is downService is down
Where is the
service?
Where is the
service?
Discovery
Announcement
PR
OX
Y
Subnet
CLI
EN
T
Discovering Services Using a Discovery Proxy
The DiscoveryClient class calls the discovery proxy; it can also be used to issue “Probe” messages inside the subnet
// The discovery endpoint points to the discovery proxyUri probeEndpointAddress = new Uri("net.tcp://localhost:8001/Probe");DiscoveryEndpoint discoveryEP = new DiscoveryEndpoint( new NetTcpBinding(), new EndpointAddress(probeEndpointAddress));// Call the discovery proxyDiscoveryClient discoveryClient = new DiscoveryClient(discoveryEP);FindResponse findResponse = discoveryClient.Find( new FindCriteria(typeof(ICalculatorService)));if (findResponse.Endpoints.Count > 0) InvokeCalculatorService(findResponse.Endpoints[0].Address);
Using Routers for Multicast Messaging
The Routing Service supports multicast, enabling publish/subscribe and distribution-style messaging
If the incoming message matches multiple filters, it will be delivered to each of the target endpoints
Multicast only works for one-way or duplex messaging; it does not work for request-response messaging
Demo 2.2Managed Service Discovery
- The Discovery Proxy Abstract Class
- The Service- Announces it’s presence in the proxy’s anouncement endpoint
- The Client- Endpoint with kind=“dynamicEndpoint”
- And dynamicEndpointConfiguration for - find scope criteria - set it’s discovery address endpoint to the proxy’s probe address
top related