SlideShare una empresa de Scribd logo
1 de 29
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/

Más contenido relacionado

Similar a WCF 4 Overview

A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
Santhu Rao
 
Web service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National WokshopWeb service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National Wokshop
Nishikant Taksande
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
Mahmoud Tolba
 
WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)
ipower softwares
 
WCF from the web developer
WCF from the web developerWCF from the web developer
WCF from the web developer
Florin Cardasim
 

Similar a WCF 4 Overview (20)

A presentation on WCF & REST
A presentation on WCF & RESTA presentation on WCF & REST
A presentation on WCF & REST
 
WCF
WCFWCF
WCF
 
Web services
Web servicesWeb services
Web services
 
10 Tricks and Tips for WCF
10 Tricks and Tips for WCF10 Tricks and Tips for WCF
10 Tricks and Tips for WCF
 
introduction to Windows Comunication Foundation
introduction to Windows Comunication Foundationintroduction to Windows Comunication Foundation
introduction to Windows Comunication Foundation
 
Steps india technologies
Steps india technologiesSteps india technologies
Steps india technologies
 
Steps india technologies .com
Steps india technologies .comSteps india technologies .com
Steps india technologies .com
 
WCF Fundamentals
WCF Fundamentals WCF Fundamentals
WCF Fundamentals
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
WCF for begineers
WCF  for begineersWCF  for begineers
WCF for begineers
 
WebSockets in JEE 7
WebSockets in JEE 7WebSockets in JEE 7
WebSockets in JEE 7
 
Web service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National WokshopWeb service- Guest Lecture at National Wokshop
Web service- Guest Lecture at National Wokshop
 
Web services in java
Web services in javaWeb services in java
Web services in java
 
Decompose That WAR! Architecting for Adaptability, Scalability, and Deployabi...
Decompose That WAR! Architecting for Adaptability, Scalability, and Deployabi...Decompose That WAR! Architecting for Adaptability, Scalability, and Deployabi...
Decompose That WAR! Architecting for Adaptability, Scalability, and Deployabi...
 
Windows Communication Foundation
Windows Communication FoundationWindows Communication Foundation
Windows Communication Foundation
 
Wcf faq
Wcf faqWcf faq
Wcf faq
 
Understanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company indiaUnderstanding Web Services by software outsourcing company india
Understanding Web Services by software outsourcing company india
 
WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)WCF (Windows Communication Foundation)
WCF (Windows Communication Foundation)
 
Wcf for the web developer
Wcf for the web developerWcf for the web developer
Wcf for the web developer
 
WCF from the web developer
WCF from the web developerWCF from the web developer
WCF from the web developer
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

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/