Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library)...

13
Marco Montanari, MSP Il Framework .net .net 3.0 .net 3.5 Web Services Introduzione generale Implementazione Microsoft WCF Il paradigma SOA secondo Microsoft I protocolli WS-* e la sicurezza nei WS C# C++ VB ... compiler IL code (+ metadata) compiler compiler compiler machine code loader verifier JIT compiler if (a > b) max = a; else max = b; IL_0004: ldloc.0 IL_0005: ldloc.1 IL_0006: ble.s IL_000c IL_0008: ldloc.0 IL_0009: stloc.2 IL_000a: br.s IL_000e IL_000c: ldloc.1 IL_000d: stloc.2 mov ebx,[-4] mov edx,[-8] cmp ebx,edx jle 17 mov ebx,[-4] mov [-12],ebx ... IL Intel code

Transcript of Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library)...

Page 1: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Marco Montanari, MSP

Il Framework .net .net 3.0.net 3.5

Web ServicesIntroduzione generaleImplementazione Microsoft

WCFIl paradigma SOA secondo MicrosoftI protocolli WS-* e la sicurezza nei WS

C# C++ VB ...

compiler

IL code(+ metadata)

compiler compiler compiler

machine code

loader

verifier

JIT compiler

if (a > b) max = a; else max = b;

IL_0004: ldloc.0IL_0005: ldloc.1IL_0006: ble.s IL_000cIL_0008: ldloc.0IL_0009: stloc.2IL_000a: br.s IL_000eIL_000c: ldloc.1IL_000d: stloc.2

mov ebx,[-4]mov edx,[-8]cmp ebx,edxjle 17mov ebx,[-4]mov [-12],ebx...

IL

Intel code

Page 2: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

.net è una implementazione di CLICommon Language Infrastructure

ECMA-334, ECMA-335

Esistono già altre implementazioni di CLI:SSCLI (Microsoft, per Windows, FreeBSD e Macintosh)Mono (per Linux)DotGNUIntel OCL (Open CLI Library)

Base Class Library

Common Language Specification

Common Language Runtime

Data and XML

VB C++ C#

Visual Studio 2008

Python

Web ServicesASP.NET

UserInterface

WPF WCF WF WCS

Nuove interfacce utenteWindows Presentation Foundation

SOAWindows Communication Foundation (WCF)

Workflow aziendaliWindows Workflow Foundation (WF)

Identità digitaleWindows CardSpace (WCS)

Nuovo linguaggio di queryLinq

Nuovi modelli linguisticiMetaprogramming (extender)Lambda-expressions

Nuove classi (poco documentate)System.Addins

Il futuro: Nuove librerieParallelFXGlee

Page 3: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Platform-independentApache Axis

Language-independentNuSoap [PHP], SOAP::Lite [Perl], Axis [Java], WCF[C#]

Standard-basedWSDL/UDDISOAPWS-*

Implementazione Microsoft:Sono parte di ASP.NET (file in formato .asmx)

.Net Framework 2.0

Devono essere accedibili da una URL su Internet Information Service (IIS)

Un Web Service non ha Interfaccia Utente (UI)Il web browser non è il client di riferimento

Client

Proxy

Processo

Application Domain

WS

Metodo

Host

Application Domain

HTTP/S

Page 4: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

WebMethod

PCs

Web

Web Services

TMainframeDBMS

Business Logic

BrowserMulti-Tier DBMSBusiness

Logic

ClientsService-Oriented DBMS

Business Logic Business

Logic

GUIClient/Server DBMSBusiness

LogicBusiness

Logic

Assurances

Messaging

SOAP

WS-Security

MTOMWS-Addressing

Metadata

WS-Policy

WSDL

WS-Discovery

UDDI

WS-MetadataExchange

WS-Transfer WS-Enumeration WS-Eventing

XML Schema

WS-ReliableMessaging

WS-Coordination

WS-AtomicTransaction

WS-BusinessActivity

WS-Trust

WS-SecureConversation

Structureand Profiles

WS-ManagementWS-FederationDevicesProfile

Foundation

SOAP / HTTP

SOAP / UDP

MIME

XML Infoset

XML 1.0XML

Namespaces

Page 5: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Caller Service

MessageEndpoint Endpoint

Endpoint

Caller Service

MessageABC A B C

A B C

Address Binding Contract

(Where) (How) (What)

Caller Service

MessageABC A B C

A B C

Metadata

Caller Service

MessageABC A B C

A B C

Bv Bv

Bv Bv

Metadata

Page 6: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Service Model

Messaging

ErrorBehavior

Hosting Environment

WPF WinForm NT Service

TCPChannel

HTTPChannel

QueueChannel

SecureChannel

ReliableChannel

Instance Behavior

Throttling Behavior

Type Integ. Behavior

TransactionBehavior

ConcurrencyBehavior

MetadataBehavior

BinaryEncoder

Text/XMLEncoder

WAS

Applicazioni

WCF

Applicazione

Processo

Computer Windows Piattaforme NON- Windows

WCF

Applicazione

Processo

WCF

Applicazione

Processo

Computer Windows

Comunicazione tra processi

Comunicazione

tra processi remoti

Comunicazione

tra piattaforme eterogenee

Client Code

Service Code

Proxy Dispatcher

Protocol 1

Protocol n

Encoder

Transport

Protocol 1

Protocol n

Encoder

Transport

Message

la necessità di un sistema di decisione comune del contratto di servizio

WSDLUDDI

La necessità di un linguaggio comune per scambiarsi messaggi

SOAP

XML

Page 7: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Nella programmazione ad oggetti

WSDL/UDDI sono contratti definiti in XML

OO Interface

WSDL UDDI

WS a partire da un WSDL approccio contract-firstSvcutil.exe

AttributiServiceContract (Che operazioni sono possibili?) WSDL

OperationContract bloccante

OperationContract(AsyncPattern=true) non bloccante

OperationContract(IsOneWay=true) senza ritorni

DataContract (Come sono fatti i dati?) XSD

DataMemberMessageContract (Come è fatto il messaggio SOAP) SOAP

MessageHeader, MessageBehavior

IIS 7.0WASProcesso generico

Binding Interop Security Session TX Duplex

BasicHttpBinding BP 1.1 N, T N N n/a

WSHttpBinding WS M, T N, T, RS N, Sì n/a

WSDualHttpBinding WS M RS N, Sì Sì

WSFederationHttpBinding Federation M N, RS N, Sì No

NetTcpBinding .NET T, M T ,RS N, Sì Sì

NetNamedPipeBinding .NET T T, N N, Sì Sì

NetPeerTcpBinding Peer T N N Sì

NetMsmqBinding .NET T, M N N, Sì No

MsmqIntegrationBinding MSMQ T N N, Sì n/a

Page 8: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Transport

IPCMSMQ

Custom

TCP HTTP

ProtocolEncoders

Binary

Text

Custom

.NETTX

Custom

Security RM

Binding

HTTP Text TXSecurity RM

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<system.serviceModel>

<services>

<service serviceType="CalculatorService">

<endpoint address="Calculator"

bindingSectionName="basicProfileBinding"

contractType="ICalculator" />

</service>

</services>

</system.serviceModel>

</configuration>

TrasportoTCP, HTTP, Named Pipes, Peer Channel, MSMQ, Custom

EncodingText, Binary, MTOM, Custom

Sicurezza End-to-EndClaims BasedTrasporto, MessaggioConfidentiality, Integrity, AuthN, AuthZ, Federation & CardSpaceX.509, Username/Password, Kerberos, SAML, Custom

End-to-End Reliable MessagingTransport-Independent QoS (In-Order / Exactly-Once)Volatile e Durable Queues per Availability

TransazioniWS-AtomicTransaction per coordinare transazioni su sistemi eterogenei

Two-Phase Commit protocolOleTransaction per sistemi WCF

Prefisso: httpObiettivo:

Massima interoperabilità a discapito dei servizi infrastrutturali

Interoperabilità:WS-I Basic Profile 1.1Parlerà con: ASMX, Java, etc

Sicurezza:Solo a livello di Trasporto (HTTPS)Credenziali del messaggio

Page 9: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Prefisso: http

Obiettivo:Server per il supporto di Ws-*

Interoperabilità:Con chi supporta WS-*

Sicurezza:Sia a livello di Trasporto che di Messaggio (Ws-*)

Default sul messaggio

Supporto:sessione

Transazioni

WS-ReliableMessaging

Prefisso: httpObiettivo:

Comunicazione sicura con WS-Federation

Quando si è al di fuori del dominio aziendale

Interoperabilità:WS-*WSE 3.0

Sicurezza:Sia a livello di Trasporto che di Messaggio (Ws-*)

Supporto:SessioneTransazioni

<bindings>

<customBinding>

<customBinding>

<binding name="ReliableTCP">

<reliableSession inactivityTimeout= 0ordered="true"/>

<binaryMessageEncoding/>

<tcpTransporttransferMode="Buffered"/>

</binding>

</customBinding>

</customBinding>

</bindings>

Modificano il comportamento a run-time del servizioPartecipano alla creazione del canale e ne può modificare il comportamentoPer estendere WCFBehaviour: diversi tipi

Service (IServiceBehaviour)(e.g Tracing degli Endpoint)

Contract (IContractBehaviour)Operation (IOperationBehavior)EndPoint (IEndpointBehavior)

Page 10: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

AutenticazioneRiconoscere mittente/destinatario

AutorizzazioneVerifico i permessi in base alle credenziali

ConfidenzialitàI messaggi devono essere visibili solo al mittente e al destinatario

IntegritàNessuno deve poter manomettere i messaggi

CredenzialiInformazioni scambiate e Usata per stabilire mittente

ClaimsInfo relative ad che possono essere derivate dalle credenzialiPossono essere usati per access control, personalizzazione, auditing, etc.

Security ModeUtilizzato per specificare ed i meccanismi di sicurezza

Message, Transport o entrambi

Sono un serie di specifiche tese a definire degli standard per risolvere alcuni dei problemi dei Web Services

Scambio di messaggi SOAP indipendente dal trasporto (e.g NON solo HTTP)Sicurezza indipendente dal trasporto (e.g NON solo HTTPS)Transazioni tra Web Services...

Si basano su nuovi Header SOAP

Transport Level SecurityConfidenzialitàIntegritàAutenticazione

VantaggiCompatibilità con sistemi esistentiVeloce; implementabile con hardware

SvantaggiHop-to-hopSet limitato di credenziali e claimsDipendenza dal trasporto!Non è un approccio Serviced-Oriented

Page 11: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Transport LevelSecurity

PuraClient CertificateWindows AuthN

Servizi offertiAutenticazioneFirma digitaleEncryptionNon ripudioEvita i replay-attack

Specifica come inserire i security token (e.gcertificato X509) nel messaggio SOAP

SOAP-basedrelazioni fidate

Richiedendo e restituendo security tokens.Sfrutta un meccanismo di scambio di token

Ci sono diversi modelli di trustingci deve essere qualcuno che garantisce per un altro

Spesso sarà il client a richiedere che qualcuno lo presenti al server

tramite un Token) al Trust Server

Scopo: Facilitare le trust relationships tra aziendeFornite da terze partiSupporto di credenziali arbitrarieBenefici:

Delega del controllo del claim a specifiche applicazioni

Page 12: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

RSTR11Cred

33

Security Token

Client Service

STS

RST

STS Security Token Service

RST Request Security Token

RSTR Request Security Token Response

T

T

T

22

Un semplice servizio

Quante istanze del servizio devono venire create?ConcurrencyModeal servizioInstanceContextMode: come devono essere create e distrutte le istanze del servizio

Come viene gestita la concorrenza?Multiple: più thread per ogni istanza di servizio. Bisogna gestire la concorrenza.Single: un solo thread che gestisce le rischieste, se è impeganto gli altri rimangono in attesaReentrant: usa un solo thread, ma può essere usato in scenari in cui un servizio chiama un secondo servizio,

Page 13: Architetture Distribuite SOA WCF - unibo.it · Mono (per Linux) DotGNU Intel OCL (Open CLI Library) Y Base Class Library Common Language Specification Common Language Runtime Data

Quante istanze di un servizio vengono create?PerCall: ad ogni chiamata viene creata una nuova istanza del servizioPerSession: una nuova istanza viene creata ad ogni sessione e questa non viene condivisa

Legata alla sessione del canaleSessione = insieme dei messaggi che fanno parte della stessa

Single: una sola istanza per tutti.

WCF è il futuro del distributed computing

WCF fornisce modello di programmazione per

la comunicazione applicativa unificato, semplice e potente

Architettura flessibile, sicura ed estendibile

Semplicità nella configurazione

Standards e specifiche WS-*

http://www.ws-i.org/ e http://www.uddi.org/

http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwebsrv/html/wsacoord.asp

Microsoft Web Services

WSE 3.0 -http://msdn.microsoft.com/webservices/webservices/building/wse/default.aspx

http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnwse/html/newwse3.asp

Architetture Microsoft e SOA

http://msdn.microsoft.com/architecture/

http://msdn.microsoft.com/architecture/soa/default.aspx

http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnbda/html/soadesign.asp

http://msdn.microsoft.com/webservices/default.aspx?pull=/library/en-us/dnbda/html/soa_vb-1.asp

Connected Systems

http://www.microsoft.com/windowsserversystem/overview/benefits/cstrial.mspx

Microsoft Windows Workflow and BizTalk

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/WWFIntro.asp

http://www.microsoft.com/biztalk/default.mspx

Windows Communication Foundation

http://windowscommunication.net/Default.aspx?tabindex=0&tabid=1

http://windowscommunication.net/collateral/pages/Introducing_WCF.htm

http://msdn.microsoft.com/windowsvista/default.aspx?pull=/library/en-us/dnlong/html/wcfarch.asp