La descarga está en progreso. Por favor, espere

La descarga está en progreso. Por favor, espere

Diego Gonzalez [C# MVP] Lagash Systems SA

Presentaciones similares


Presentación del tema: "Diego Gonzalez [C# MVP] Lagash Systems SA"— Transcripción de la presentación:

1

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

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

4 ¿Qué es Windows Communication Foundation?
Ayer: Remoting COM D/COM WSE MSMQ ASMX COM+ Varias opciones solapadas The Windows Communication Foundation, which was code-named “Indigo,” is a technology by which pieces of software can communicate with one another. There are many other such technologies, including COM and DCOM, RMI, MSMQ, and WebSphere MQ. Each of those works will in a particular scenario, not so well in others, and is of no use at all in some cases. The Windows Communication Foundation is meant to work well in any circumstance in which software entities must be made to communicate with one another. In fact, it is meant to always be the very best option: It provides performance that is about as good as, if not better than, any other alternative; it offers at least as many features and probably several more; and it will certainly be the easiest solution to program. Hoy: Windows Communication Foundation Una única opción para todos los casos

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

6 ¿Cómo funciona? Datos Modelo de servicio Metadatos Capa de canael
Address, Binding, Contract, y Behaviors Metadatos Concretely, the Windows Communication Foundation consists of a number of class libraries within the .NET 3 Framework. The most important of those class libraries are the Service Model and the Channel Layer. The Service Model provides you with a small, simple language for modeling how you want your software to communicate. In the language of the Service Model, a piece of software that responds to communications over a network is a service, a service has one or more endpoints, and each endpoint consists of an address, a binding, and a contract. The address defines where the service is located. The binding specifies the set of protocols that it uses to communicate. Contracts define the messages that services can send and receive. At runtime, the Windows Communication looks at the binding that you have defined and assembles, from the Channel Layer, a stack of channels that implement the protocols specified by the binding that you chose. Then, when you have data to send, the Windows Communication Foundation translates your data into a message, and passes the message through the stack of channels it has assembled, so that your message is send on its way in accordance with the protocols identified by your binding. Messages that are received are decoded by the channel stack, and translated into the data that you are expecting. Implementations of new protocols can readily be added to the channel layer. Thus, the Windows Communication Foundation protects your investment by allowing you to continue to use the same simple programming framework provided by the Service Model with any communication protocol you may encounter. Addresses, bindings and contracts defined with the Service Model are all automatically described in metadata, which by default, is in the form of the standard Web Services Description Language. By virtue of the metadata, developers of client application can learn about the endpoints of a service, find out the address, binding and contract of each of those endpoints. They are able to generate client code for communicating with the service from that information provided by the metadata. However, the Service Model language has an additional element that one can use in defining how a piece of software is to communicate that does not surface in the metadata: behaviors. Behaviors are used to control how messages are handled internally, such as whether new instances of your classes are constructed to handle each incoming data, or whether all of the incoming data is sent to the same instance of your classes. It is because such internal processing details don’t affect how a client and a server communicate with one another that behavior options are not included in the metadata for a service. Capa de canael Protocols, Encoders, y Transports Mensages

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

8 ¿Cómo se usa? Definición del Contrato Implementación del Contrato
[ServiceContract] public interface IMyInterface { [OperationContract] public MyOutputType MyMethod(MyInputType myData); } Definición del Contrato [ServiceBehavior(InstanceContextMode=Single] public class MyService: IMyInterface { public MyOutputType MyMethod(MyInputType myData) { //my code } Implementación del Contrato (Service Type) The development of a Windows Communication Foundation service begins with a developer defining a contract. That is done by writing an interface in a .NET programming language, and then adding attributes from the Service Model that designate the interface as a Windows Communication Foundation contract, and one or more of the methods as being included in the contract. The next step is to implement the contract, which is done simply by writing a class that implements the interface. A class that implements an interface that is designated as a Windows Communication Foundation contract is called a “service type.” How the Windows Communication Foundation conveys data to and from the service type from the outside can be controlled by adding behaviors to the service type definition using the ServiceBehavior attribute. For example, the instance context mode attribute shown here controls whether all incoming data is sent to a new instance of the service type, or to a single instance, amongst other options. Finally, an administrator configures endpoints for the service by associating an address and a binding with the contract and service type provided by the programmer. The configuration of endpoints is defined in a regular .NET configuration file, but a configuration editor is provided so that administrators don’t have to write configuration XML. <service name=“MyService”> <endpoint address=“MyAddress” binding=“netTcpBinding” contract=“IMyInterface” /> <service/> Configuración del Endpoint

9 Auto-Host dentro de cualquier .NET process:
¿Cómo se instala? Web Host en IIS: 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 Auto-Host dentro de cualquier .NET process: Disponible para cualquier servicio Cualquier tipo de aplicación: Consola, ventanas, servicios, controles…

10 Un servicio símple

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

12 Se 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 processes Secure, reliable duplexed Basis for WS-* interop Supports WS-Security, WS-RM, WS-Tx Basic Profile 1.1 Interop and Intergration w/ASMX Purpose

13 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>

14 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=“ " /> </binding> </customBinding> </bindings> </system.serviceModel> </configuration>

15 Distintos bindings

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

17 Addresses La porción “scheme” de una URI define el protocolo:
NetNamedPipesBinding NetMSMQBinding NetTcpBinding BasicHttpBinding, WsHttpBinding Binding net pipe://… net msmq://… net tcp://… Scheme Algunos han sido estandarizados, y se pueden crear nuevos

18 La dirección de un endpoint es relativa una dirección base:
Addresses La dirección de un endpoint es relativa una dirección base: <services> <host> <baseAddresses> <add baseAddress=" </baseAddresses> </host> <service name=“MyService”> <endpoint address=“MyEndpointAddress” binding=“wsHttpBinding” bindingConfiguration=“MyReliableBinding” contract=“IMyInterface” /> <service/> </services> Para servicios en IIS, la baseAddress es la dirección del directorio virtual

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

20 Como se envían los mensajes MyOutputType y MyInputType?
Contracts Veamos 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; } Se puede optar por el viejo XmlSerializer: [ServiceContract] [XmlSerializerFormat] public interface IMyInterface

21 Transacciones y confiabilidad

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

23 Seguridad Autenticación Autorizació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

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

25 Administracion Integrated Management Management Model Tools
Microsoft Operations Manager 2005 Management Pack Integrated Management Management Model Microsoft Management Model Designer Tools CIM Studio ScriptOMatic PowerShell Configuration Editor Trace Viewer PerfMon PowerShell CmdLet Instruments (Data & Control Points) Configuration System WMI Provider Tracing and Logging Performance Counters Management Interface

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

27 Integración Client Service Integration Strategy ASMX WCF WCF ASMX
Configure WCF components to use BasicHttpBinding Remoting WCF WSE 2 WCF Remoting WSE 2 Upgrade Remoting & WSE 2 components to WCF WCF WSE 3 WSE 3 WCF For HTTP, use properly configured WSHttpBinding For TCP, custom TCP transport sample on NETFX 3.com WCF COM+ Use COMSVCConfig.exe to wrap COM+ app w/WCF endpoint COM WCF Service Monikers

28 Extensibilidad Contract Contract Client Code parameters Service Type
WSDL Exporter Client Code parameters Service Type parameters Operation Invoker Parameter Inspector Parameter Inspector Message Formatter Message Formatter Message Inspector Instance Provider Typed Proxy Message Inspector Dispatcher Operation Selector Channel Custom Channel Custom Channel Channel Channel Custom Channel Custom Channel Channel Transport Channel byte[] Transport Channel byte[] Encoder Encoder Custom Transport Custom Encoder Custom Encoder Custom Transport * Added by configuring the runtime with behaviors * Added by adding binding elements to the binding

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

30 © 2004 Microsoft Corporation. All rights reserved.
4/18/2017 3:20 PM © 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. © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Descargar ppt "Diego Gonzalez [C# MVP] Lagash Systems SA"

Presentaciones similares


Anuncios Google