WCF 4 Overview
-
Upload
mariano-rodriguez -
Category
Technology
-
view
21 -
download
0
description
Transcript of WCF 4 Overview
![Page 1: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/1.jpg)
WCF 4.0 OverviewMariano O. Rodriguez
![Page 2: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/2.jpg)
AgendaIntroducciónContratosBindingBehaviorsRESTNuevo en WCF4
![Page 3: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/3.jpg)
ABC de WCFAddress (Donde)Binding (Como)Contract (Que)
![Page 4: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/4.jpg)
WCF Channel LayerCliente
Protocol Channel 1
Protocol Channel 2
Protocol Channel N
Encoder
Transport
Servicio
Protocol Channel 1
Protocol Channel 2
Protocol Channel N
Encoder
Transport
![Page 5: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/5.jpg)
Contratos
![Page 6: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/6.jpg)
Contratos
Servicio
Datos
Mensaje
Describe las operaciones que el servicio realiza. Mapea tipos CLR
(WSDL).
Describe la estructura de datos. Mapea tipos CLR (XSD).
Define la estructura del mensaje. Mapea tipos CLR (SOAP message)
![Page 7: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/7.jpg)
Service Contract
[ServiceContract]public interface ICalculator{ [OperationContract] ComplexProblem Do(ComplexProblem p);}
![Page 8: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/8.jpg)
Service Contract: OneWay[ServiceContract]public interface IOneWayCalculator{ [OperationContract(IsOneWay=true)]
void Do(ComplexProblem p);}
![Page 9: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/9.jpg)
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);}
![Page 10: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/10.jpg)
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);}
![Page 11: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/11.jpg)
Data Contract
[DataContract]public class ComplexNumber{ [DataMember] public double Real;
[DataMember] public double Imaginary { get; set; }
}
![Page 12: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/12.jpg)
Message Contract[MessageContract]public class ComplexProblem{ [MessageHeader] public string Operation { get; set;} [MessageBody] public ComplexNumber Op1 { get; set; } [MessageBody] public ComplexNumber Op2 { get; set; }}
![Page 13: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/13.jpg)
Bindings
![Page 14: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/14.jpg)
Standard BindingsName 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
![Page 15: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/15.jpg)
Binding en Configuracion
<system.serviceModel> <services> <service name="CalculatorService"> <endpoint address=“http://localhost/calculator" binding="basicHttpBinding" contractType="ICalculator" /> </service> </services></system.serviceModel>
![Page 16: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/16.jpg)
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>
![Page 17: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/17.jpg)
Behaviors
![Page 18: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/18.jpg)
Behaviors OverviewImplementan semántica del sistema
Para el desarrollador Concurrencia Instanciación Transacciones Impersonation
Para operaciones Throttling Metadata
![Page 19: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/19.jpg)
InstanciaciónPer CallSingletonSession
![Page 20: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/20.jpg)
Throttling
<behaviors> <behavior configurationName="CalculatorBehavior" > <serviceThrottling maxConcurrentCalls="10" maxConnections="10" maxInstances="10" maxPendingOperations="10" /> </behavior></behaviors>
![Page 21: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/21.jpg)
RESTAcrónimo de REpresentational State TransferEs un estilo de arquitectura
Mejor uso de HTTPMenor complejidadInteroperable
![Page 22: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/22.jpg)
Principios de RESTIdentificar recursos por medio de URIsUso de verbos HTTPLink resourcesPresentación en múltiples formatos
(JSON/POX)Comunicación Stateless
![Page 23: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/23.jpg)
Identifica recursos con URIs
http://myservice/roomshttp://myservice/rooms(3)http://myservice/Colors(red)http://myservice/Transactions(1145001)
![Page 24: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/24.jpg)
Verbos HTTP usadosGet: obtiene la representación de un recursoPut: actualiza un recursoPost: crea un nuevo recursoDelete: elimina un recurso
![Page 25: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/25.jpg)
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>
![Page 26: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/26.jpg)
REST en WCF
![Page 27: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/27.jpg)
REST en WCFBasado en nuevos atributos
WebGet (Get)WebInvoke (Post/Put/Delete)
Permite definir el tipo de SerializacionJSONXML
Soporte de streaming retornando un Stream
![Page 28: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/28.jpg)
Nuevo en WCF 4Simplificación de configuraciónActivación en IIS (.svc opcional)Soporte de WS-Discovery (udp based)Soporte de Router
BridgingRouting por contenido
Mejoras para RESTPagina de ayudaIntegración con rutas de MVCCaching
![Page 29: WCF 4 Overview](https://reader033.fdocuments.in/reader033/viewer/2022061112/545672b5af79597b578b7014/html5/thumbnails/29.jpg)
ReferenciasA Guide to Designing and Building RESTful
Web Services with WCF 3.5http://msdn.microsoft.com/en-us/library/dd203052.asp
xWCF REST Starter Kit
http://aspnet.codeplex.com/releases/view/24644Windows Server AppFabric Training Kit
http://www.microsoft.com/download/en/details.aspx?id=7956
ODatahttp://www.odata.org/