SlideShare a Scribd company logo
Mariano O. Rodriguez
Agenda
 Introducción
 Contratos
 Binding
 Behaviors
 REST
 Nuevo en WCF4
ABC de WCF
 Address (Donde)
 Binding (Como)
 Contract (Que)
WCF Channel Layer
       Cliente              Servicio

  Protocol Channel 1   Protocol Channel 1

  Protocol Channel 2   Protocol Channel 2

  Protocol Channel N   Protocol Channel N

       Encoder              Encoder

      Transport            Transport
Contratos
Contratos
                  Describe las operaciones que el servicio
    Servicio
                    realiza. Mapea tipos CLR (WSDL).


               Describe la estructura de datos. Mapea tipos
     Datos
                                CLR (XSD).


               Define la estructura del mensaje. Mapea tipos
    Mensaje
                            CLR (SOAP message)
Service Contract
[ServiceContract]
public interface ICalculator
{
    [OperationContract]
    ComplexProblem Do(ComplexProblem p);
}
Service Contract: OneWay
[ServiceContract]
public interface IOneWayCalculator
{
    [OperationContract(IsOneWay=true)]
    void Do(ComplexProblem p);
}
Service Contract: Duplex
[ServiceContract(
      CallbackContract=typeof(ICalculatorResults)]
public interface ICalculatorProblems
{
    [OperationContract(IsOneWay=true)]
    void SolveProblem (ComplexProblem p);
}

public interface ICalculatorResults
{
    [OperationContract(IsOneWay=true)]
    void Results(ComplexProblem p);
}
Service Contracts: Faults
[ServiceContract]
public interface ICalculator
{
    [OperationContract]
    [FaultContract(typeof(DivideByZeroException))]
    ComplexProblem Do(ComplexProblem p);
}

try {
    return n1 / n2;
}
catch (DivideByZeroException e) {
    var f = new DivideByZeroException(“Calc Failure”);
    throw new FaultException<DivideByZeroException>(f);
}
Data Contract
[DataContract]
public class ComplexNumber
{
    [DataMember]
    public double Real;

    [DataMember]
    public double Imaginary { get; set; }
}
Message Contract
[MessageContract]
public class ComplexProblem
{
    [MessageHeader]
    public string Operation { get; set;}
    [MessageBody]
    public ComplexNumber Op1 { get; set; }
    [MessageBody]
    public ComplexNumber Op2 { get; set; }
}
Bindings
Standard Bindings
Name                      Transport    Encoding
BasicHttpBinding          HTTP/HTTPS   Text/MTOM
NetTcpBinding             TCP          Binary
NetPeerTcpBinding         P2P          Binary
NetNamedPipeBinding       IPC          Binary
WSHttpBinding             HTTP/HTTPS   Text/MTOM
WSFederationHttpBinding   HTTP/HTTPS   Text/MTOM
WSDualHttpBinding         HTTP/HTTPS   Text/MTOM
NetMsmqBinding            MSMQ         Binary
MsmqIntegrationBinding    MSMQ         Binary
WebHttpBinding            HTTP/HTTPS   Text/Binary
Binding en Configuracion
<system.serviceModel>
  <services>
    <service name="CalculatorService">
      <endpoint address=“http://localhost/calculator"
                  binding="basicHttpBinding"
                  contractType="ICalculator" />
    </service>
  </services>
</system.serviceModel>
Custom Bindings
<bindings>
    <customBinding>
        <binding configurationName="Binding1">
            <reliableSession bufferedMessagesQuota="32"
                   inactivityTimeout="00:10:00"
                   maxRetryCount="8"
                   ordered="true" />
            <httpsTransport manualAddressing="false"
                   maxMessageSize="65536"
                   hostNameComparisonMode="StrongWildcard"/>
            <textMessageEncoding maxReadPoolSize="64"
                   maxWritePoolSize="16"
                   messageVersion="Default"
                   writeEncoding="utf-8" />
        </binding>
    </customBinding>
</bindings>
Behaviors
Behaviors Overview
 Implementan semántica del sistema
    Para el desarrollador
       Concurrencia
       Instanciación
       Transacciones
       Impersonation
   Para operaciones
       Throttling
       Metadata
Instanciación
 Per Call
 Singleton
 Session
Throttling
<behaviors>
  <behavior configurationName="CalculatorBehavior" >
    <serviceThrottling maxConcurrentCalls="10"
                maxConnections="10"
                maxInstances="10"
                maxPendingOperations="10" />
  </behavior>
</behaviors>
REST
 Acrónimo de REpresentational State Transfer
 Es un estilo de arquitectura
    Mejor uso de HTTP
    Menor complejidad
    Interoperable
Principios de REST
 Identificar recursos por medio de URIs
 Uso de verbos HTTP
 Link resources
 Presentación en múltiples formatos (JSON/POX)
 Comunicación Stateless
Identifica recursos con URIs

http://myservice/rooms
http://myservice/rooms(3)
http://myservice/Colors(red)
http://myservice/Transactions(1145001)
Verbos HTTP usados
 Get: obtiene la representación de un recurso
 Put: actualiza un recurso
 Post: crea un nuevo recurso
 Delete: elimina un recurso
Link Resources
<order self=’http://example.com/orders(1234)’>
  <amount>23</amount>
  <product
  ref=’http://example.com/products(4554)’ />
  <customer
  ref=’http://example.com/customers(1234)’ />
</order>
REST en WCF
REST en WCF
 Basado en nuevos atributos
    WebGet (Get)
    WebInvoke (Post/Put/Delete)
 Permite definir el tipo de Serializacion
    JSON
    XML
 Soporte de streaming retornando un Stream
Nuevo en WCF 4
   Simplificación de configuración
   Activación en IIS (.svc opcional)
   Soporte de WS-Discovery (udp based)
   Soporte de Router
     Bridging
     Routing por contenido
 Mejoras para REST
   Pagina de ayuda
   Integración con rutas de MVC
   Caching
Referencias
 A Guide to Designing and Building RESTful Web
  Services with WCF 3.5
    http://msdn.microsoft.com/en-us/library/dd203052.aspx
 WCF REST Starter Kit
    http://aspnet.codeplex.com/releases/view/24644
 Windows Server AppFabric Training Kit
    http://www.microsoft.com/download/en/details.aspx?id=7956
 OData
    http://www.odata.org/

More Related Content

PDF
Java and the blockchain - introducing web3j
PPTX
Configuring mule jms_withweblogicjms
PPTX
Learning Solidity
PPTX
Mule parsing with json part2
PDF
Protobuf & Code Generation + Go-Kit
PDF
Weaving the ILP Fabric into Bigchain DB
PPTX
Java Session
DOC
1 serializando y deserializando datos en red
Java and the blockchain - introducing web3j
Configuring mule jms_withweblogicjms
Learning Solidity
Mule parsing with json part2
Protobuf & Code Generation + Go-Kit
Weaving the ILP Fabric into Bigchain DB
Java Session
1 serializando y deserializando datos en red

Similar to WCF 4 Overview (20)

DOC
WCF tutorial
PPT
PPTX
WCF Fundamentals
PPTX
A presentation on WCF & REST
PPTX
Wcf for the web developer
PPTX
WCF from the web developer
PDF
Building RESTful Services with WCF 4.0
PPTX
Windows communication foundation ii
PPTX
WCF for begineers
PPTX
1. WCF Services - Exam 70-487
PPT
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
PPT
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
PPT
Service Oriented Development With Windows Communication Foundation 2003
PPT
introduction to Windows Comunication Foundation
PPTX
Understanding Web Services by software outsourcing company india
PPTX
Web service, wcf, web api
PPT
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
PPTX
Windows Communication Foundation
PPTX
What's new in Wcf4
WCF tutorial
WCF Fundamentals
A presentation on WCF & REST
Wcf for the web developer
WCF from the web developer
Building RESTful Services with WCF 4.0
Windows communication foundation ii
WCF for begineers
1. WCF Services - Exam 70-487
Tulsa Tech Fest2008 Service Oriented Development With Windows Communication F...
WCFPresentation.ppt WCFPresentation.ppt WCFPresentation.ppt
Service Oriented Development With Windows Communication Foundation 2003
introduction to Windows Comunication Foundation
Understanding Web Services by software outsourcing company india
Web service, wcf, web api
Service Oriented Development With Windows Communication Foundation Tulsa Dnug
Windows Communication Foundation
What's new in Wcf4
Ad

Recently uploaded (20)

PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPT
Teaching material agriculture food technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
Electronic commerce courselecture one. Pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
The AUB Centre for AI in Media Proposal.docx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Programs and apps: productivity, graphics, security and other tools
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Teaching material agriculture food technology
Assigned Numbers - 2025 - Bluetooth® Document
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Ad

WCF 4 Overview

  • 2. Agenda  Introducción  Contratos  Binding  Behaviors  REST  Nuevo en WCF4
  • 3. ABC de WCF  Address (Donde)  Binding (Como)  Contract (Que)
  • 4. WCF Channel Layer Cliente Servicio Protocol Channel 1 Protocol Channel 1 Protocol Channel 2 Protocol Channel 2 Protocol Channel N Protocol Channel N Encoder Encoder Transport Transport
  • 6. Contratos Describe las operaciones que el servicio Servicio realiza. Mapea tipos CLR (WSDL). Describe la estructura de datos. Mapea tipos Datos CLR (XSD). Define la estructura del mensaje. Mapea tipos Mensaje CLR (SOAP message)
  • 7. Service Contract [ServiceContract] public interface ICalculator { [OperationContract] ComplexProblem Do(ComplexProblem p); }
  • 8. Service Contract: OneWay [ServiceContract] public interface IOneWayCalculator { [OperationContract(IsOneWay=true)] void Do(ComplexProblem p); }
  • 9. Service Contract: Duplex [ServiceContract( CallbackContract=typeof(ICalculatorResults)] public interface ICalculatorProblems { [OperationContract(IsOneWay=true)] void SolveProblem (ComplexProblem p); } public interface ICalculatorResults { [OperationContract(IsOneWay=true)] void Results(ComplexProblem p); }
  • 10. Service Contracts: Faults [ServiceContract] public interface ICalculator { [OperationContract] [FaultContract(typeof(DivideByZeroException))] ComplexProblem Do(ComplexProblem p); } try { return n1 / n2; } catch (DivideByZeroException e) { var f = new DivideByZeroException(“Calc Failure”); throw new FaultException<DivideByZeroException>(f); }
  • 11. Data Contract [DataContract] public class ComplexNumber { [DataMember] public double Real; [DataMember] public double Imaginary { get; set; } }
  • 12. Message Contract [MessageContract] public class ComplexProblem { [MessageHeader] public string Operation { get; set;} [MessageBody] public ComplexNumber Op1 { get; set; } [MessageBody] public ComplexNumber Op2 { get; set; } }
  • 14. Standard Bindings Name Transport Encoding BasicHttpBinding HTTP/HTTPS Text/MTOM NetTcpBinding TCP Binary NetPeerTcpBinding P2P Binary NetNamedPipeBinding IPC Binary WSHttpBinding HTTP/HTTPS Text/MTOM WSFederationHttpBinding HTTP/HTTPS Text/MTOM WSDualHttpBinding HTTP/HTTPS Text/MTOM NetMsmqBinding MSMQ Binary MsmqIntegrationBinding MSMQ Binary WebHttpBinding HTTP/HTTPS Text/Binary
  • 15. Binding en Configuracion <system.serviceModel> <services> <service name="CalculatorService"> <endpoint address=“http://localhost/calculator" binding="basicHttpBinding" contractType="ICalculator" /> </service> </services> </system.serviceModel>
  • 16. Custom Bindings <bindings> <customBinding> <binding configurationName="Binding1"> <reliableSession bufferedMessagesQuota="32" inactivityTimeout="00:10:00" maxRetryCount="8" ordered="true" /> <httpsTransport manualAddressing="false" maxMessageSize="65536" hostNameComparisonMode="StrongWildcard"/> <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Default" writeEncoding="utf-8" /> </binding> </customBinding> </bindings>
  • 18. Behaviors Overview  Implementan semántica del sistema  Para el desarrollador  Concurrencia  Instanciación  Transacciones  Impersonation  Para operaciones  Throttling  Metadata
  • 19. Instanciación  Per Call  Singleton  Session
  • 20. Throttling <behaviors> <behavior configurationName="CalculatorBehavior" > <serviceThrottling maxConcurrentCalls="10" maxConnections="10" maxInstances="10" maxPendingOperations="10" /> </behavior> </behaviors>
  • 21. REST  Acrónimo de REpresentational State Transfer  Es un estilo de arquitectura  Mejor uso de HTTP  Menor complejidad  Interoperable
  • 22. Principios de REST  Identificar recursos por medio de URIs  Uso de verbos HTTP  Link resources  Presentación en múltiples formatos (JSON/POX)  Comunicación Stateless
  • 23. Identifica recursos con URIs http://myservice/rooms http://myservice/rooms(3) http://myservice/Colors(red) http://myservice/Transactions(1145001)
  • 24. Verbos HTTP usados  Get: obtiene la representación de un recurso  Put: actualiza un recurso  Post: crea un nuevo recurso  Delete: elimina un recurso
  • 25. Link Resources <order self=’http://example.com/orders(1234)’> <amount>23</amount> <product ref=’http://example.com/products(4554)’ /> <customer ref=’http://example.com/customers(1234)’ /> </order>
  • 27. REST en WCF  Basado en nuevos atributos  WebGet (Get)  WebInvoke (Post/Put/Delete)  Permite definir el tipo de Serializacion  JSON  XML  Soporte de streaming retornando un Stream
  • 28. Nuevo en WCF 4  Simplificación de configuración  Activación en IIS (.svc opcional)  Soporte de WS-Discovery (udp based)  Soporte de Router  Bridging  Routing por contenido  Mejoras para REST  Pagina de ayuda  Integración con rutas de MVC  Caching
  • 29. Referencias  A Guide to Designing and Building RESTful Web Services with WCF 3.5  http://msdn.microsoft.com/en-us/library/dd203052.aspx  WCF REST Starter Kit  http://aspnet.codeplex.com/releases/view/24644  Windows Server AppFabric Training Kit  http://www.microsoft.com/download/en/details.aspx?id=7956  OData  http://www.odata.org/