windows communication foundation diego gonzalez [c# mvp] lagash systems sa [email protected]

30

Upload: pilar-navarro-quintana

Post on 03-Feb-2016

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com
Page 2: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Windows Communication Foundation

Diego Gonzalez [C# MVP]Lagash Systems [email protected]

Page 3: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication

Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 4: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

¿Qué es Windows Communication Foundation?

Varias opciones solapadas

Remoting COMD/COM

COM+MSMQWSE

ASMX

Una única opción para todos los casos

Windows Communication Foundation

Ayer:

Hoy:

Page 5: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 6: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

¿Cómo funciona?

Datos

Modelo de servicio

Address, Binding, Contract, y Behaviors

Capa de canael

Protocols, Encoders, y Transports

Mensages

Metadatos

Page 7: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 8: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

¿Cómo se usa?[ServiceContract]public interface IMyInterface { [OperationContract] public MyOutputType MyMethod(MyInputType myData);}

Definición del Contrato

<service name=“MyService”> <endpoint address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” /><service/>

Configuración delEndpoint

[ServiceBehavior(InstanceContextMode=Single]public class MyService: IMyInterface { public MyOutputType MyMethod(MyInputType myData) { //my code … }}

Implementacióndel Contrato

(Service Type)

Page 9: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

¿Cómo se instala?

• Solo para servicios HTTP en Windows XP® SP2 & WS2K3• Cualquier servicio en Windows Vista® y Windows Server®

“Longhorn” • Escalabilidad, confiabilidad y seguridad probadas• Requiere un archivo.svc para identificar el Service Type

Web Host en IIS:

Auto-Host dentro de cualquier .NET process:

• Disponible para cualquier servicio• Cualquier tipo de aplicación: Consola, ventanas, servicios,

controles…

Page 10: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Un servicio símple

Page 11: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Que es Windows Communication Foundation? • ¿Como funciona?• ¿Como se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 12: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

BindingsSe pueden utilizar bindings pre-definidos:

<endpoint name=“MyService” address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” />

NetPeerTcpBinding

NetMSMQBinding

NetNamePipesBinding

NetTcpBinding

WsHttpBinding

BasicHttpBinding

Binding

.NET Peer Peer

.NET.NET via MSMQ

.NET.NET across processesSecure, reliable duplexed

.NET.NET across processesSecure, reliable duplexed

Basis for WS-* interopSupports WS-Security, WS-RM, WS-Tx

Basic Profile 1.1 Interop and Intergration w/ASMX

Purpose

Page 13: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Se pueden personalizar bindings pre-definidos

<services> <service name=“MyService”> <endpoint address=“MyAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/></services><bindings> <wsHttpBinding> <binding name=“MyReliableBinding”>

<reliableSession enabled=“true” ordered=“true” </binding> </wsHttpBinding></bindings>

Bindings

Page 14: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Se pueden crear bindings propios<?xml version=“1.0” encoding=“UTF-8” ?><configuration> <system.serviceModel> <services> <service

name=“MyService”><endpoint address=“MyAddress” binding=“customBinding” bindingConfiguration=“MyCustomBinding” contract=“IMyInterface” />

</service> </services> <bindings> <customBinding> <binding name="MyCustomBinding"> <reliableSession advancedFlowControl="true” /> <security authenticationMode=“Kerberos” />

<binaryMessageEncoding /> <tcpTransport maxMessageSize=“9223372036854775807" />

</binding> </customBinding> </bindings> </system.serviceModel></configuration>

Bindings

Page 15: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Distintos bindings

Page 16: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 17: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Addresses

La porción “scheme” de una URI define el protocolo:

Algunos han sido estandarizados, y se pueden crear nuevos

NetNamedPipesBinding

NetMSMQBinding

NetTcpBinding

BasicHttpBinding, WsHttpBinding

Binding

net pipe://…

net msmq://…

net tcp://…

http://...

Scheme

Page 18: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Addresses

La dirección de un endpoint es relativa una dirección base:

Para servicios en IIS, la baseAddress es la dirección del directorio virtual

<services> <host> <baseAddresses> <add baseAddress="http://localhost:8000/MyBaseAddress"/> </baseAddresses> </host> <service name=“MyService”> <endpoint address=“MyEndpointAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/></services>

Page 19: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 20: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

ContractsVeamos el contrato:

[ServiceContract]public interface IMyInterface{ [OperationContract] public MyOutputType MyMethod(MyInputType myData);}

Como se envían los mensajes MyOutputType y MyInputType?

• Serialization es realizada po DataContractSerializer por defecto• Soporta tipos.NET Framwork automáticamente• Tipos definidos por el usuario requiren Data Contracts:

[DataContract]public class MyDataContract{ [DataMember]

public string MyField; }

[ServiceContract][XmlSerializerFormat]public interface IMyInterface

• Se puede optar por el viejo XmlSerializer:

Page 21: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Transacciones y confiabilidad

Page 22: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 23: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

SeguridadAutenticación

• El mensaje lleva un token de seguridad• El token contiene “claims” sobre el usuario• El tipo de token se configura en el binding

• Se incluye soporte para: • Windows (Kerberos o NTLM)• Username (un nomre y una password)• Certificados X.509• CardSpace tokens• SAML tokens

• Se pueden hacer tokens propios

Autorización

• Autorización con ServiceAuthorizationBehavior • Opciones:

• Usuarios autenticados con tokens de Windows • Principal Permissions• ASP.NET Role Provider

• Usuarios autenticados con cualquier token: • Un ServiceAuthorization personalizado

Page 24: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 25: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Administracion

Instruments

(Data & Control Points)Configuration

System

ToolsConfiguration

Editor

WMI Provider

CIM StudioScriptOMaticPowerShell

Tracingand

Logging

Trace Viewer

Performance

Counters

PerfMon

ManagementInterface

PowerShellCmdLet

Management Model Microsoft Management

Model Designer

Integrated ManagementMicrosoft

Operations Manager 2005 Management

Pack

Page 26: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Agenda• ¿Qué es Windows Communication Foundation? • ¿Cómo funciona?• ¿Cómo se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 27: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Integración

COM WCF Service Monikers

WCF COM+ Use COMSVCConfig.exe to wrap COM+ app w/WCF endpoint

WCFWSE 3

WSE 3WCF

For HTTP, use properly configured WSHttpBindingFor TCP, custom TCP transport sample on NETFX 3.com

RemotingWCF

WSE 2WCF

WCFRemoting

WCFWSE 2

Upgrade Remoting & WSE 2 components to WCF

ASMXWCF

WCFASMX

Configure WCF components to use BasicHttpBinding

Client Service Integration Strategy

Page 28: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

Extensibilidad

Client Code

parameters

Typed Proxy

Channel

Channel

Transport Channelbyte[]

Encoder

Service Type

parameters

Dispatcher

Channel

Channel

Transport Channelbyte[]

Encoder

ContractContract

Message Inspector

Custom Channel

Custom Transport

Custom Encoder

Custom Encoder

Custom Transport

Custom Channel

Custom Channel

Custom Channel

Operation Invoker

Message Formatter

Parameter Inspector

Message Formatter

WSDL Exporter

Instance Provider

* Added by configuring the runtime with behaviors* Added by adding binding elements to the binding

Message Inspector

Parameter Inspector

Operation Selector

Page 29: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

En Resumen• ¿Que es Windows Communication Foundation? • ¿Como funciona?• ¿Como se usa?• Bindings• Addresses• Contracts• Seguridad• Administración• Integración y extensibilidad

Page 30: Windows Communication Foundation Diego Gonzalez [C# MVP] Lagash Systems SA diegog@lagash.com

© 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,

it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.