2. About the Presenter
As a key member of Microsoft Web Services design
team, he was responsible for several of the key
patents implemented in the .NET WCF
implementation, and is a named contributor to
two of the WS-* standards (WS-Discovery and
WS-Soap-over-UDP)
3. Introduction
⢠Web Services
â What are they
â Why/When to use
â How to design for (SOA)
â Technologies (legacy)
â WCF
4. Take-away
⢠Web Services enable a new way of building distributed
applications in a loosely coupled, independent way
⢠Web Services are based on layers of standards and
building blocks which are supported by modern tools
⢠Service Oriented Architecture starts by thinking of the
interfaces first; useful enterprise patterns exist
⢠.NET 3.0 introduced Windows Communication Foundation
which obsoletes previous communication frameworks
⢠WCF exposes easy access to most WS layers
⢠WCF is based on a Contract, Binding, and Address
5. Agenda
⢠Web Services Concepts
â Introducing the web services concepts
â Case study - car dealership â discussion
⢠Building Web Services
â Existing building blocks and standards
â Principles of SOA
â The car dealership architecture â discussion
⢠Web Services Technology
â Legacy Technologies
â .NET 3.0 / WCF [20] concepts
⢠MiniSample [10] The WCF car dealer
12. WS-Addressing
⢠How do we identify a service? EPR
⢠URI or URI + RefProp
⢠<wsa:EndpointReference âŚ>
<wsa:Address>http://www.b.com/1</wsa:Address>
<wsa:ReferenceProperties>
<blah:CustomerKey>123456789</fblah:CustomerKey>
</wsa:ReferenceProperties>
</wsa:EndpointReference>
⢠MessageID, RelatesTo, Action
13. [WS-]SOAP Over TCP
⢠Wire format
⢠HTTP no longer transport of choice
⢠Performance
⢠No transport level security (https)
⢠Also â Soap Over UDP
⢠Connection sharing [non-standard]
14. WS-Security
⢠HTTPS only provides transport level
security â consider the intermediary
⢠Integrity & confidentiality
⢠Using SOAP header
⢠Username, X.509, Kerberos, XML Sig
⢠Performance vs. TLS ?
15. WS-Discovery vs. UDDI
⢠Using discovery
â .NET vs. java âlocatorâ thinking
⢠UDDI successes and failures
â Trust, Service Definition
⢠WS-Discovery
â limited scope
â Present and Future
17. Loose Coupling
⢠Sacrifices interface optimization
⢠Achieve flexible interoperability
⢠.. And ease of change
⢠.. And does not come naturally
18. Loose and Tight Coupling
Tightly Loosely
Msg Style RPC Doc
Msg Path Hardcode Route
Technology Homogenous Heterogeneous
Binding Early, fixed Late
Interaction Synchronous Asynchronous
Model Reuse Broad applicability
Adaptation Recoding Transformation
Behavior Anticipated Unexpected
* Adapted from âloosely coupledâ by Doug Kaye
19. SOA Patterns
⢠Self Service Client
⢠Service Locator (mostly Javathink)
⢠Broker, Router Variation, XML firewall
⢠Serial and Parallel process pattern
⢠Cached object pattern
⢠Queue and MessageBus
⢠Pub/Sub and distributed observer pattern
20. SOA Patterns - Implementation
⢠The Message is the Media
⢠Contract First/Contract Second
⢠Fowlerisms
â Service Layer
â Transform View
â Remote Façade
â Data Transfer Object
â Service Stub [testing]
23. WCF Presented
⢠Released in .NET 3.0
⢠Diverse Stack
⢠Address / Binding / Contract
⢠Unique Features
â Existing building blocks
â Ease of implementation, deployment, maint
â XML compression, performance
24. ABC
⢠Address, Binding, Contract
â EPR
â System bindings, parameters, custom, and
custom channels
â Interface/class
32. Take-away and Summary
Use Web Services for applications, components
Use Standards (WS-*) and building blocks
Architect using SOA patterns (routers, locatorsâŚ)
Use .NET 3.0/WCF as communication layer
Define the Contract; configure Binding, and
Address
Add on transports, reliability, security
35. Web Services Defined
⢠Interoperable machine-to-machine
interaction
⢠Using SOAP and XML (some use REST)
⢠Service and Contract
⢠Message
⢠SOA (service oriented architecture)
36. Sending Out An S.O.A
⢠The Need for SOA
⢠Real world problems
⢠Integration Nightmares
⢠Increasing Complexity
45. More WFC building blocks
⢠Transactions
⢠Behaviors
â Lifetime
46. Code: Channel Programming
encoder = new TextMessageEncodingBindingElement();
transport = new TcpTransportBindingElement();
binding = new CustomBinding(encoder, transport);
IChannelFactory<IRequestChannel> factory =
binding.BuildChannelFactory<IRequestChannel>(); factory.Open();
address = new EndpointAddress("net.tcp://192.168.0.2:5555/");
IRequestChannel channel = factory.CreateChannel(address); channel.Open();
request = Message.CreateMessage(factory.MessageVersion, "hello");
reply = channel.Request(request);
Console.Out.WriteLine(reply.Headers.Action);
reply.Close(); channel.Close(); factory.Close(); } }
47. Code: Reliability
BindingElementCollection bindingElements = new BindingElementCollection();
ReliableSessionBindingElement session = new
ReliableSessionBindingElement(); session.Ordered = true;
bindingElements.Add(session); bindingElements.Add(new
CompositeDuplexBindingElement()); bindingElements.Add(new
UdpTransportBindingElement()); Binding playerInfoBinding = new
CustomBinding(bindingElements);
48. Code: Reliability
BindingElementCollection bindingElements = new BindingElementCollection();
ReliableSessionBindingElement session = new
ReliableSessionBindingElement(); session.Ordered = true;
bindingElements.Add(session); bindingElements.Add(new
CompositeDuplexBindingElement()); bindingElements.Add(new
UdpTransportBindingElement()); Binding playerInfoBinding = new
CustomBinding(bindingElements);
Uri playerInfoAddress = new Uri( "soap.udp://localhost:16000/");
using(ServiceHost service = new ServiceHost(typeof(playerInfoService))) {
service.AddServiceEndpoint(typeof(IUpdatePlayerInfoContract),
playerInfoBinding, playerInfoAddress); service.Open();
... // more service code here }
49. Code: Callback (and duplex)
interface IMyContractCallback { [OperationContract] void OnCallback(); }
[ServiceContract(CallbackContract = typeof(IMyContractCallback))]
interface IMyContract { [OperationContract] void DoSomething(); }
public sealed class InstanceContext : CommunicationObject, ... { public
InstanceContext(object implementation); ... // More members }
class MyCallback : IMyContractCallback { public void OnCallback() {...} }
IMyContractCallback callback = new MyCallback(); InstanceContext context =
new InstanceContext(callback);
IMyContractCallback callback = new MyCallback(); InstanceContext context =
new InstanceContext(callback); MyContractClient proxy = new
MyContractClient(context); proxy.DoSomething();