SlideShare a Scribd company logo
Distributed Applications,
Web Services, and WCF


  Yaniv Pessach
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)
Introduction

  • Web Services
    − What are they
    − Why/When to use
    − How to design for (SOA)
    − Technologies (legacy)
    − WCF
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
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
Web Services Properties
• Contract defines interaction
• Loosely Coupled, avoid dependencies
• True Platform Independence
• Build, maintain, version, deploy separately
• External, Internal, Intra-application
Message Exchange Patterns
• Synchronous, Asynchronous, Fire & forget
• Uncorrelated/Correlated by transport/Msg
• Request/Response (RPC style) vs. Publish /
  Subscribe vs. One-Way
• Multicast
• Queuing helps logical fire & forget
The Fjord Dealership
• Dealer buys cars, sells cars
• Deals with other dealers (get cars on lot)
• Verify VIN
• Approve Loan
• Accept Credit-cards
• Etc.
Discussion: Identify WS
• In groups, discuss the needed web services
  − External
  − Internal
  − Reliability, performance, data requirements?
Web Services Layers
• Base standards
• Logical Protocol
• Semantic Protocols                  ws-     Orch
                                   transact   estra
                                              tion

                               Ws-policy               WSDL
                     ws-security        ws-discovery


                        XML         SOAP      SOAP ws-addr
                                              OVER
                                              *
Standards
• Transports          • WS-Reliability
• WSDL                • WS-transaction
• WS-Addressing       • WS-Orchestration
• Profiles and WS-I   • UDDI and WS-
• WS-Security           Discovery
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
[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]
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 ?
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
SOA
• Contract
• Encapsulate
• Distinct Service
• Services exchange data, not share behavior
Loose Coupling
• Sacrifices interface optimization
• Achieve flexible interoperability
• .. And ease of change
• .. And does not come naturally
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
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
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]
Architect Fjord WS
• Major Services
• Building Blocks
• Discussion!
Legacy Technologies
• Microsoft
  − RPC
  − DCOM
  − .NET 1.1 Remoting
  − .NET 1.1 WS
• Issues
  − Interoperability
  − Specific limitations
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
ABC
• Address, Binding, Contract
  − EPR
  − System bindings, parameters, custom, and
    custom channels
  − Interface/class
Topics
• Hosting
• Channels and extensibility
  − Existing channels, transports, reliability,
    security
• Profiles
• Configuration
Code: Contract
[ServiceContract()] public interface ISellCar
{
    [OperationContract] double price(int vin);
    [OperationContract (IsOneWay=true)]
    Void notifyInterest(int vin);
}
Code: Client
• Svcutil.exe http://...?wsdl


using (CarProxy proxy = new CarProxy())
{
    double result = proxy.price(617894332);
}
Code: Server
• Impl: public class CarService: ISellCar {….}
• Hosted: something.svc
<@Service language=c# class=“….CarService“ %>
• SelfHost: using (ServiceHost host = new
  ServiceHost(typeof(CarService), new
  Uri("http://..."))) { host.Open();
  Thread.Sleep(1000000); host.Close(); }
Config: Server [1]
<configuration …. > <system.serviceModel>
  <services> <service
  behaviorConfiguration=“CarServiceBehavior"
  type=…. > <endpoint address=""
  binding="wsHttpBinding"
  bindingConfiguration="Binding1"
  contract=“….ISellCar" /> </service> </services>
Config: Server [2]
<configurationName=“CarServiceBehavior"
  returnUnknownExceptionsAsFaults="True">
  </behavior> </behaviors>
<bindings> <wsHttpBinding> <binding
  configurationName="Binding1" />
  </wsHttpBinding> </bindings>
  </system.serviceModel>
</configuration>
Fjord With WCF
• Construct pseudo/code
• Discussion!
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
More Information

• http://www.yanivpessach.com/soa_read
  more.txt
• Contact me – yaniv@yanivpessach.com
Backup slides
Web Services Defined
• Interoperable machine-to-machine
  interaction
• Using SOAP and XML (some use REST)
• Service and Contract
• Message
• SOA (service oriented architecture)
Sending Out An S.O.A
• The Need for SOA
• Real world problems
• Integration Nightmares
• Increasing Complexity
SOAP Sample
<soap:Envelope
mlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <getProductDetailsxmlns=…>
         <productID>827635</productID>
      </getProductDetails>
   </soap:Body>
</soap:Envelope>
WS Layered Usage
• External
  − E.g. process credit card transaction
• Internal (‘inside the firewall’)
  − EAI e.g. accounting to helpdesk apps
• Intra-application
  − Modular design, flexibility, common blocks
Benefits Revisited
• Built separately
  − different teams, timelines, platforms
  − enable focused teams
  − minimize accidental dependencies
• Deployed separately
  − Performance, troubleshooting, versioning
Web Services Properties
• Contract defines interaction
• Loosely Coupled
Standards – Time is right




* Source: Computer Networks Fourth Edition , Andrew Tanenbaum
Standards – discuss specifics
• Important
• Tool support
• Too many to choose from
WS-Transaction
• Long lived transaction
• Problems of 2-phase commit
• Based on roll-back
• Flexible
WS-Orchestration
• Upper level integration
• Relies on lower levels
• Stabilizing
• Think of it as BizTalk
More WFC building blocks
• Transactions
• Behaviors
  − Lifetime
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(); } }
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);
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 }
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();

More Related Content

What's hot (20)

PDF
Hindes_Active_2016Gz2
William Hindes
 
PPTX
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
READIFY
 
PPTX
Web changesandasp4 upload
READIFY
 
PPT
Azure Services Platform Oc Event Ned
Wes Yanaga
 
PPTX
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
READIFY
 
PDF
Chapter10 web
READIFY
 
PDF
Service-Oriented Architecture (SOA)
WSO2
 
PPTX
WCF
VISHAL DONGA
 
PPTX
Manageability of Windows Azure BizTalk Services (WABS)
BizTalk360
 
PPT
Oracle BPEL Presentation
shub54
 
PDF
Arquitectura orientada a servicios
brizna39
 
PPTX
Sharepoint 2010 Geliştirme Araçları
ÇözümPARK
 
DOC
Oracle soa/Fusion developer
Sudhakar P
 
KEY
Design & Implementation Issues in a Contemporary Remote Laboratory Architecture
The University of Queensland
 
PPT
Pro Dev Briefing Irvine Wesyppt23
Wes Yanaga
 
PPTX
Hybrid Solutions with the current BizTalk Server 2013 R2 platform
BizTalk360
 
PPTX
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
Lucas Jellema
 
PDF
Apache Etch Introduction @ FOSDEM 2011
grandyho
 
PPT
Web services and SOA
Subin Sugunan
 
PPSX
WCF LOB SDK at CNUG
clineer
 
Hindes_Active_2016Gz2
William Hindes
 
ASP.NET 4 & Web Dev in Visual Studio 2010 - Alex Mackey, Readify
READIFY
 
Web changesandasp4 upload
READIFY
 
Azure Services Platform Oc Event Ned
Wes Yanaga
 
Visual Studio 2010 IDE Enhancements - Alex Mackey, Readify
READIFY
 
Chapter10 web
READIFY
 
Service-Oriented Architecture (SOA)
WSO2
 
Manageability of Windows Azure BizTalk Services (WABS)
BizTalk360
 
Oracle BPEL Presentation
shub54
 
Arquitectura orientada a servicios
brizna39
 
Sharepoint 2010 Geliştirme Araçları
ÇözümPARK
 
Oracle soa/Fusion developer
Sudhakar P
 
Design & Implementation Issues in a Contemporary Remote Laboratory Architecture
The University of Queensland
 
Pro Dev Briefing Irvine Wesyppt23
Wes Yanaga
 
Hybrid Solutions with the current BizTalk Server 2013 R2 platform
BizTalk360
 
Introducing SOA and Oracle SOA Suite 11g for Database Professionals
Lucas Jellema
 
Apache Etch Introduction @ FOSDEM 2011
grandyho
 
Web services and SOA
Subin Sugunan
 
WCF LOB SDK at CNUG
clineer
 

Similar to SOA and WCF (Windows Communication Foundation) basics (20)

PPT
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
Jason Townsend, MBA
 
PPT
Session 1: The SOAP Story
ukdpe
 
PPTX
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio
 
PPT
WCF
Vishwa Mohan
 
PPT
webservices overview
elliando dias
 
PPT
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
Jason Townsend, MBA
 
PPTX
nptl cc video.pptx
MunmunSaha7
 
PDF
Week2 cloud computing week2
Ankit Gupta
 
PPT
Service Oriented Development With Windows Communication Foundation 2003
Jason Townsend, MBA
 
PPT
Session 1 Shanon Richards-Exposing Data Using WCF
Code Mastery
 
PPTX
WCjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
OmkarTalkar1
 
PDF
Advantage of WCF Over Web Services
Siva Tharun Kola
 
PPTX
Web service, wcf, web api
AbdeliDhankot
 
PPTX
An Overview of Web Services: SOAP and REST
Ram Awadh Prasad, PMP
 
PPTX
Complete Architecture and Development Guide To Windows Communication Foundati...
Abdul Khan
 
PPTX
Web programming
sowfi
 
PDF
Java Web Services [1/5]: Introduction to Web Services
IMC Institute
 
PPT
Windows Communication Foundation
David Truxall
 
PPTX
Service Oriented Architecture
Luqman Shareef
 
PPTX
Web services
ishmecse13
 
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
Jason Townsend, MBA
 
Session 1: The SOAP Story
ukdpe
 
Advancio, Inc. Academy: Web Sevices, WCF & SOAPUI
Advancio
 
webservices overview
elliando dias
 
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
Jason Townsend, MBA
 
nptl cc video.pptx
MunmunSaha7
 
Week2 cloud computing week2
Ankit Gupta
 
Service Oriented Development With Windows Communication Foundation 2003
Jason Townsend, MBA
 
Session 1 Shanon Richards-Exposing Data Using WCF
Code Mastery
 
WCjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...
OmkarTalkar1
 
Advantage of WCF Over Web Services
Siva Tharun Kola
 
Web service, wcf, web api
AbdeliDhankot
 
An Overview of Web Services: SOAP and REST
Ram Awadh Prasad, PMP
 
Complete Architecture and Development Guide To Windows Communication Foundati...
Abdul Khan
 
Web programming
sowfi
 
Java Web Services [1/5]: Introduction to Web Services
IMC Institute
 
Windows Communication Foundation
David Truxall
 
Service Oriented Architecture
Luqman Shareef
 
Web services
ishmecse13
 
Ad

Recently uploaded (20)

PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PDF
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
NLJUG Speaker academy 2025 - first session
Bert Jan Schrijver
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
AI Agents in the Cloud: The Rise of Agentic Cloud Architecture
Lilly Gracia
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Ad

SOA and WCF (Windows Communication Foundation) basics

  • 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
  • 6. Web Services Properties • Contract defines interaction • Loosely Coupled, avoid dependencies • True Platform Independence • Build, maintain, version, deploy separately • External, Internal, Intra-application
  • 7. Message Exchange Patterns • Synchronous, Asynchronous, Fire & forget • Uncorrelated/Correlated by transport/Msg • Request/Response (RPC style) vs. Publish / Subscribe vs. One-Way • Multicast • Queuing helps logical fire & forget
  • 8. The Fjord Dealership • Dealer buys cars, sells cars • Deals with other dealers (get cars on lot) • Verify VIN • Approve Loan • Accept Credit-cards • Etc.
  • 9. Discussion: Identify WS • In groups, discuss the needed web services − External − Internal − Reliability, performance, data requirements?
  • 10. Web Services Layers • Base standards • Logical Protocol • Semantic Protocols ws- Orch transact estra tion Ws-policy WSDL ws-security ws-discovery XML SOAP SOAP ws-addr OVER *
  • 11. Standards • Transports • WS-Reliability • WSDL • WS-transaction • WS-Addressing • WS-Orchestration • Profiles and WS-I • UDDI and WS- • WS-Security Discovery
  • 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
  • 16. SOA • Contract • Encapsulate • Distinct Service • Services exchange data, not share behavior
  • 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]
  • 21. Architect Fjord WS • Major Services • Building Blocks • Discussion!
  • 22. Legacy Technologies • Microsoft − RPC − DCOM − .NET 1.1 Remoting − .NET 1.1 WS • Issues − Interoperability − Specific limitations
  • 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
  • 25. Topics • Hosting • Channels and extensibility − Existing channels, transports, reliability, security • Profiles • Configuration
  • 26. Code: Contract [ServiceContract()] public interface ISellCar { [OperationContract] double price(int vin); [OperationContract (IsOneWay=true)] Void notifyInterest(int vin); }
  • 27. Code: Client • Svcutil.exe http://...?wsdl using (CarProxy proxy = new CarProxy()) { double result = proxy.price(617894332); }
  • 28. Code: Server • Impl: public class CarService: ISellCar {….} • Hosted: something.svc <@Service language=c# class=“….CarService“ %> • SelfHost: using (ServiceHost host = new ServiceHost(typeof(CarService), new Uri("http://..."))) { host.Open(); Thread.Sleep(1000000); host.Close(); }
  • 29. Config: Server [1] <configuration …. > <system.serviceModel> <services> <service behaviorConfiguration=“CarServiceBehavior" type=…. > <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1" contract=“….ISellCar" /> </service> </services>
  • 30. Config: Server [2] <configurationName=“CarServiceBehavior" returnUnknownExceptionsAsFaults="True"> </behavior> </behaviors> <bindings> <wsHttpBinding> <binding configurationName="Binding1" /> </wsHttpBinding> </bindings> </system.serviceModel> </configuration>
  • 31. Fjord With WCF • Construct pseudo/code • Discussion!
  • 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
  • 37. SOAP Sample <soap:Envelope mlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <getProductDetailsxmlns=…> <productID>827635</productID> </getProductDetails> </soap:Body> </soap:Envelope>
  • 38. WS Layered Usage • External − E.g. process credit card transaction • Internal (‘inside the firewall’) − EAI e.g. accounting to helpdesk apps • Intra-application − Modular design, flexibility, common blocks
  • 39. Benefits Revisited • Built separately − different teams, timelines, platforms − enable focused teams − minimize accidental dependencies • Deployed separately − Performance, troubleshooting, versioning
  • 40. Web Services Properties • Contract defines interaction • Loosely Coupled
  • 41. Standards – Time is right * Source: Computer Networks Fourth Edition , Andrew Tanenbaum
  • 42. Standards – discuss specifics • Important • Tool support • Too many to choose from
  • 43. WS-Transaction • Long lived transaction • Problems of 2-phase commit • Based on roll-back • Flexible
  • 44. WS-Orchestration • Upper level integration • Relies on lower levels • Stabilizing • Think of it as BizTalk
  • 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();