costruire web service oggi e domani giuseppe guerrasio architect, microsoft

45

Upload: raimonda-de-simone

Post on 01-May-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft
Page 2: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Costruire Web Service oggi e domani

Giuseppe GuerrasioArchitect, Microsoft

Page 3: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Ad un punto di svolta

Singola Applicazione

Singola Piattaforma Piattaforme Integrate

Sistemi Distribuiti

Page 4: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Funzionalità logiche ricorrenti

Un modello in evoluzione

Page 5: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

La Strategia: Connected System

Fornire una piattaforma integrata di prodotti e tecnologie completa ed interoperabile

… che include tool (dev e mgmt), framework, infrastruttura e piattaforma

…che copra l’intera gamma bisogni (client, device, e server, workflow,dati, messagging , etc)

…che sia interoperabile by design con le altre piattaforme

… che abbracci tre principi architetturali chiave Service Orientation

Claims-Based Security

Model Driven Software

Page 6: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Microsoft Application PlatformConnected Systems

Page 7: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WS-* Architecture

Foundation

Applicazioni e Infrastruttura

Transport

Connected Connected ApplicationsApplications ManagementManagement BusinessBusiness

ProcessProcess……

SecuritySecuritySecuritySecurity

TrustTrust

Secure Secure ConversationConversation

Messaging Messaging (SOAP, Addressing, MTOM, Eventing)(SOAP, Addressing, MTOM, Eventing)

XML XML (XML, XSD, XPath)(XML, XSD, XPath)

Me

tad

ata

Me

tad

ata

(WS

DL

, P

oli

cy,

(WS

DL

, P

oli

cy,

Dis

cove

ry,

ME

X)

Dis

cove

ry,

ME

X)

HTTPHTTP TCPTCP SMTPSMTP ……

ReliabilityReliabilityReliable Reliable

MessagingMessaging

TransactionsTransactionsAtomic Atomic

TransactionTransaction

CoordinationCoordination

Business Business ActivityActivity

Page 8: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

ASP.NET Web Services, WSE e WCF(Indigo)

ASP.NET Web Services

Web Services Enhancements Advanced WS-* Implementation

Foundation for Web services and service-oriented applications

To

day

Unified distributed applications frameworkWindows Communication

Foundation(Indigo)

To

mo

rro

w

Page 9: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Activation and Hosting

WAS Avalon *.EXE NT Service COM+

MessagingHTTP

Channel

TCPChannel

UDPChannel

X-ProcChannel

QueueChannel

SOAP SecurityChannel

SOAP ReliabilityChannel

Text/XMLEncoder

BinaryEncoder

Service Runtime

Contracts

ThrottlingBehavior

TransactionBehavior

ActivationBehavior

ConcurrencyBehavior

Cmd/ControlFacilities

ErrorBehavior

MetadataBehavior

InstanceBehavior

InspectionFacilities

DataContract

MessageContract

ServiceContract

Policy andBinding

Indigo

Il Bus :Interoperabilità

Network

App

AltriStack

Application App

BizTalkAdapter

App

WSE

Assurances

Messaging

SOAP

WS-Security

MTOMWS-Addressing

Metadata

WS-Policy

WSDL

UDDI

WS-MetadataExchange

XML Schema

WS-ReliableMessaging

WS-Coordination

WS-AtomicTransaction

WS-BusinessActivity

WS-Trust

WS-SecureConversation

Infrastructureand Profiles

WS-ManagementWS-FederationDevicesProfile

Foundation

SOAP / HTTPMIME

XML Infoset

XML 1.0XML

Namespaces

WS-* Protocols

Page 10: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Temi Supporto WS .NET v2.0

InteroperabilitàProduttivitàEstendibilità

Page 11: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Bisogno di Oggi: Interoperabilità

Miglioramenti alle caratteristiche di Interoperabilità con il supporto del Basic Profile 1.1

WS compatibili di default con specifico attributo attivatoEmit Conformance Claim supportato lato client solo > 1.1 sp1

Supporto per SOAP 1.2Server side controllato via .config Client side Wsdl.exe supporta entrambi 1.1 per default (wsdl.exe set /protocol a SOAP12) , SoapProtocolVersion come proprietà nel proxy

Miglioramenti al supporto per la generazione del servizio a partire dal contratto (“contract-first”)

wsdl.exe /serverInterface generazione interfaccia da implementare Verifica a run time della contract integrity

Supporto per l’utilizzo dei GenericsAdesempio:. public List<int> ReturnIntegerList()

Nullable Value TypesUtilizzo di Nullable<T>

Page 12: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Client più semplici da sviluppareNuovo modello asincrono event-based

Utilizza XxxAsync e XxxCompleted event Evento richiamato sul thread chiamante Sotituisce BeginXxx, EndXxx mantenuti per compatibilità

Supporto per il databinding nel proxyIn V2.0 per default nel proxy vengono generate public property invece di fieldWsdl.exe con /fields switch per comportamento V1.1

Client-side type sharing Individua gli schemi equivalenti e genera un unico CLR type

Bisogno di Oggi: Produttività

Page 13: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Custom serialization disponibileIXMLSerializable esposto nativamente

Possibilità di gestire con proprio codice la serializzazione

.NET Framework 2.0 introduce [XmlSchemaProvider]

Usato con IXmlSerializable per indicare i metodi statici per generare lo schema

Deprecato IXmlSerializable.GetSchema

Custom proxy code generation con SchemaImporterExtension

Classe astratta che abilita la generazione di custom code quando si importano schemi nel proxy

Bisogno di oggi:Estendibilità

Page 14: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Supporto in System.Net per la determinazione dello stato di rete (online/offline)detect automatico della modifica del Web ProxySupporto automatico della compressione nel Proxy

Disponibile anche client side la compressione oltre che nativamente in II6, service.EnableDecompression = true;

Costruzione a Design Time dei Serializzatori per i Proxy

Generazione attraverso tool da riga di comando sgen.exeIntegrazione in VIsual Studio

Semplificazione nell’utilizzo delle Default Credential

service.UseDefaultCredentials = true

Altre Estensioni alla v2.0

Page 15: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE è Security

Page 16: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE 3.0

Semplificare lo sviluppo di Semplificare lo sviluppo di Web Service SicuriWeb Service Sicuri

Semlpificare lo sviluppo Semlpificare lo sviluppo di soluzioni Service Orienteddi soluzioni Service Orientedutilizzando WS-* protocolsutilizzando WS-* protocolse .NET Framework v2.0e .NET Framework v2.0

WSE v3.0 con .NET WSE v3.0 con .NET Framework v2.0 strada principale versoFramework v2.0 strada principale verso

WFC ( Indigo)WFC ( Indigo)

IndigoIndigo

Page 17: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE 3.0Applicazione di WS-Security con scenari attraverso le Policy

Descrivono i requisiti per i messaggi in ingresso ed in uscita attraverso Policy AssertionSuperano le limitazioni delle Policy in WSE 2.0

Request e Response separatiComplessità , necessita di pensare a basso livello alle singole funzionalità ed aggregarle

Supporto di tool per Visual Studio 2005Estensione dell’ ASMX programming model

Trasporti alternativi es. TCPHosting environment alternativi es. Console appsMessaging APIs ancora supportate ma deprecate

SoapClient, SoapService

Message Transmission Optimization Mechanism (MTOM)

MTOM sostituisce DIME & WS-Attachments

Page 18: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Turnkey Security ScenarioBasati su industry best practiceOgni scenario rappresenta una assertion

UsernameForCertificate

AnonymousForCertificate

UsernameOverTransport

Kerberos

MutualCertificate

Page 19: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE 3.0 Session ManagementStateful SCTs

WSE 2.0 richiede che il servizio mantenga lo stato del SCT In WSE 3.0 lo stato può essere mantenuto con lo stesso SCTPermette al SCT di ristabilire una sessione

SCT CancellationIn WSE 2.0 SCT scade a timeoutIn WSE 3.0 c’è la possibilità di cancellare una session

Page 20: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Unifica le attuali tecnologie MS distribuite in un modello unicoAppropriato per l’uso on-machine, cross machine, and cross Internet

Modello di programmazione unificato per costruire rapidamenteservice-oriented application

per Windows

Interoperabile con applicazioni di altre piattaforme con ampio supporto per WS*-Architecture Integrabile con gli altri windows distributed stacks

UnificazioneUnificazione

IntegrazioneIntegrazione

ServiceServiceOrientationOrientation

Windows Communication Foundation

(Indigo)

Implementa le best practices per costruire applicazioni distribuite basate sui principi della service orientation

Page 21: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

ApplicationApplication

Service ModelService Model

MessagingMessaging

Hosting Hosting EnvironmentsEnvironments ASP.NETASP.NETASP.NETASP.NET AvalonAvalonAvalonAvalon WinFormWinFormWinFormWinForm NT ServiceNT ServiceNT ServiceNT Service COM+COM+COM+COM+

TCPTCPChannelChannel

TCPTCPChannelChannel

HTTPHTTPChannelChannel

HTTPHTTPChannelChannel

QueueQueueChannelChannelQueueQueue

ChannelChannel

SecureChannelSecure

ChannelReliableReliableChannelChannelReliableReliableChannelChannel

Instance Instance BehaviorBehaviorInstance Instance BehaviorBehavior

Throttling Throttling BehaviorBehavior

Throttling Throttling BehaviorBehavior

Type Integ. Type Integ. BehaviorBehavior

Type Integ. Type Integ. BehaviorBehavior

TransactionTransactionBehaviorBehavior

TransactionTransactionBehaviorBehavior

ConcurrencyConcurrencyBehaviorBehavior

ConcurrencyConcurrencyBehaviorBehavior

ErrorErrorBehaviorBehavior

ErrorErrorBehaviorBehavior

MetadataMetadataBehaviorBehaviorMetadataMetadataBehaviorBehavior

BinaryBinaryEncoderEncoderBinaryBinary

EncoderEncoder

Text/XMLText/XMLEncoderEncoder

Text/XMLText/XMLEncoderEncoder

…………

……

…………

WCF Architettura

WASWASWASWAS

Page 22: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Client e Service

ServiceService

MessageMessage

ClientClient

Page 23: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Endpoint

ServiceServiceClientClient

EndpointEndpoint

EndpointEndpoint

EndpointEndpoint

EndpointEndpoint MessageMessage

Page 24: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Address Binding Contract

Address, Binding, Contract

ServiceServiceClientClient

EndpointEndpoint

EndpointEndpoint

EndpointEndpoint

EndpointEndpoint MessageMessage

Dove ? Come ? Cosa ?

ABC

A B C

A B C

A B C

Page 25: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Inside Binding

Transport

IPCMSMQ

Custom

TCP HTTP

ProtocolEncoders

Binary

Text

Custom

.NETTX

Custom

Security RM

BindingHTTP Text TXSecurity RM

Page 26: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

BasicHttpBindingWsHttpBindingWsDualHttpBinding

Binding

NetTcpBindingNetNamedPipeBindingNetMsmqBindingNetPeerTcpBinding

InteroperabInteroperabiliili

WCF / WCFWCF / WCF

Page 27: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Windows Activation Service Windows Activation Service (WAS)(WAS)

HTTP.SYHTTP.SYSS

TCP TCP Transport Transport ListenerListener

Named Pipes Named Pipes Transport Transport ListenerListener

HTTP HTTP Listener Listener Adapter Adapter

(IIS7)(IIS7)

NP Listener NP Listener AdapterAdapter

TCP Listener TCP Listener AdapterAdapter

Windows Activation Service

Nuovo modello di attivazione unificato condiviso da ASP.NET, IIS7, e WCF

Supporto di protocolli multipli

Page 28: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WAS/IIS7 Architecture

W3SVCW3SVC

Application PoolApplication Pool

Application Application

Application Application

Application

Application PoolApplication Pool

Application Application

Application Application

Application

Application PoolApplication Pool

Application Application

Application Application

Application

Application PoolApplication Pool

Application Application

Application Application

Application

Application PoolApplication Pool

Application Application

Application Application

Application

Application PoolApplication Pool

Application Application

Application Application

Application Windows Activation ServiceWindows Activation Service

Config MgrConfig Mgr

Process MgrProcess Mgr

HTTP.SYS

HTTP MgrHTTP Mgr

HTTP.SYS Indigo Net.TCPListener

Indigo Net.PipeListener

IIS 7.0 Benefici ArchitetturaProcess Activation GeneralizzatoSupporto Estendibile multi-protocol Health Management ConfigurabileSide by Side deploymentUnified Management ModelCompletamente Componentizzato

Web.config

Web.config

Web.config

Applicationhost.config

Page 29: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Guida verso WCFASMX

Quando siamo in dubbio,... usiamo ASMX

WSEASMX + WS-* in particolare Sicurezza

Enterprise ServicesPer servizi aggiuntivi (Tx Distribuite)

essenzialmente x-machine communication dentro i confini del servizio

System.MessagingPer il messaging

Remotingx-domain & custom transport

Page 30: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

ASMX Guida

UtilizzareConformance claim “Service” interfaceDifferenti indirizzi per ciascun binding“Open content model” per i dati

Evitarerpc/encodedASP.Net state o “dipendenze dal trasporto” (esempio: HttpContext)SoapExtension

Page 31: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE Guida

Utilizzare I suggerimenti della ASMX guidaHTTP transport“Turnkey” policy (WSE3)MTOM (WSE3)

EvitareQualunque tipo di estensioni da SoapPortCustom transportIXmlElement per i data typeDIME

Page 32: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Da WSE a Indigo Codice Client

public class myHelloWorld{        static void Main (string[ ] args) {

HelloWorldWSE helloWorld = new HelloWorldWSE();

string response = helloWorld.Hello("hello");}

}

HelloWorld helloWorld = new HelloWorld();

Note: Modifiche configurative richieste

Page 33: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Da WSE a Indigo Codice Server

using Microsoft.Web.Services3;

[WebService]class HelloWorld {    [WebMethod]    public string Hello (string text) {       MessageSignature signature = (MessageSignature)

RequestSoapContext.Current.Security.Elements[0];        if (!signature.SigningToken.Principal.IsInRole("BUILTIN\

Administrators"))            throw new AuthorizationException("Access denied");         return String.Format("Hello, {0}", text);    }}Note: Configuration entry changes are required

using System.ServiceModel;

[PrincipalPermission(SecurityAction.Demand, null, "BUILTIN\Administrators")]

[ServiceContract]

[OperationContract]

Page 34: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

RiepilogoLa piattaforma applicativa Microsoft è pensata per materializzare “Connected System”I Web Service sono una componente fondamentale e la piattaforma

Roadmap chiara e definita verso Windows Communication Foundation (WCF)

Supporto migliorato in .NET v2.0 perInteroperabilità, Produttività, Estendibilità

WSE 3.0 porta WS-Security in .NET 2.0Percorso di migrazione\interoperabilità per WCF garantito

Page 35: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

© 2005 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Page 36: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Policy in WSE 3.0Descrivono i requisiti per i messaggi in ingresso ed in uscita attraverso Policy AssertionSuperano le limitazioni delle Policy in WSE 2.0

Request e Response separati

Complessità , necessita di pensare a basso livello alle singole funzionalità ed aggregarle

Policy files semplificatiSemplificazione con i turnkey security assertion

Nuovo object model per le policy serviceProxy.SetPolicy("ClientPolicy");

Utilizzo di attributi sia lato Server che Client[Policy("UserNameOverX509")]

Page 37: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Policy Pipeline ArchitectureLe Policy decrivono la input Le Policy decrivono la input

pipelinepipelineInput Input

Soap MessageSoap Message Se

curity

Se

curity

Tra

cing

Tra

cing

Cu

sto

mC

us

tom

Se

curity

Se

curity

Tra

cing

Tra

cing

Cu

sto

mC

us

tom

EsecuzioneEsecuzioneCodice Codice

ApplicativoApplicativoOutputOutputSoap MessageSoap Message

Le Policy assertion Le Policy assertion trasformano il trasformano il

messaggiomessaggio

… … e si esegue la output Pipelinee si esegue la output Pipeline

Page 38: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Turnkey Security ScenarioUsernameForCertificate

Application Application ServerServer

InternetInternet IntranetIntranet

Auth con Auth con username/ username/ PasswordPassword

Confidenzialità, e firmaConfidenzialità, e firmarichiesta con client keyrichiesta con client keyprotetta con il certificatoprotetta con il certificatoserverserver

Confidenzialità, e firmaConfidenzialità, e firmarisposta con chiave risposta con chiave fornita dal clientfornita dal client

Username/Password Username/Password per Autenticazioneper Autenticazione

Page 39: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Example Policy Assertionpublic class UsernameOverX509Assertion : SecurityPolicyAssertion{ // constructors public UsernameOverX509Assertion() { } // properties public TokenProvider<UsernameToken> UsernameTokenProvider

{ get { } set { } } public TokenProvider<X509SecurityToken> X509TokenProvider {

get { } set { } } // methods public override SoapFilter

CreateClientInputFilter(FilterCreationContext context) { } public override SoapFilter

CreateClientOutputFilter(FilterCreationContext context) { } public override SoapFilter

CreateServiceInputFilter(FilterCreationContext context) { } public override SoapFilter

CreateServiceOutputFilter(FilterCreationContext context) { } public override IEnumerable<KeyValuePair<string, Type>>

GetExtensions() { } public override XmlSchema GetSchema() { } public override void ReadXml(XmlReader reader) { } public override void WriteXml(XmlWriter writer) { }}

Page 40: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Client con Policy Assertion via CodiceUtilizzo di una Turnkey Security Assertion

StockQuoteClient proxy;Policy myPolicy = new Policy();myPolicy.Assertions.Add(new UsernameOverX509Assertion());proxy.SetPolicy(myPolicy);

Utilizzo di una Custom Policy Assertion e.g. XML Schema Validation

StockQuoteClient proxy;Policy myPolicy = new Policy();myPolicy.Assertions.Add(new MyCustomAssertion());proxy.SetPolicy(myPolicy);

Page 41: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Asymmetric key (X509 Certificate) lento per l’invio di messaggi multipli

WS-SecureConversation definisce il Security Context Token (SCT)

Ottimizzazione del messaging

Veloce nel caso di messaggi multipli (client makes > 2)

Raddoppio del throghput

Sessioni con Secure Conversation

Richiesta per SCTRichiesta per SCT

SCT Issued al clientSCT Issued al client

Messaggi Multipli Messaggi Multipli Firmati e cifrati con SCTFirmati e cifrati con SCT

ClientClient ServerServer

Page 42: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Integrazione con VS2005 e .NET v2.0

Supporto di tool per Visual Studio 2005

Estensione dell’ ASMX programming model

Trasporti alternativi es. TCPHosting environment alternativi es. Console apps

Messaging APIs ancora supportate ma deprecate

SoapClient, SoapService

Page 43: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Estensione del ASMX programming Model Esempio: ASMX Web Service via TCP e Custom Hostpublic class StockServicepublic class StockService System.Web.Services.WebServiceSystem.Web.Services.WebService {{

[WebMethod][WebMethod]public StockQuote[] StockQuoteRequest([string[] public StockQuote[] StockQuoteRequest([string[]

symbols) {symbols) { } } }}

static void Main(string[] args)static void Main(string[] args) {{

Uri to = new Uri( "soap.tcp://StockService/StockQuote");Uri to = new Uri( "soap.tcp://StockService/StockQuote");EndpointReference EPR = new EndpointReference(to);EndpointReference EPR = new EndpointReference(to);SoapReceivers.Add (EPR, typeof (StockService));SoapReceivers.Add (EPR, typeof (StockService));

}}

Page 44: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

Supporto per MTOMMessage Transmission Optimization Mechanism (MTOM)MTOM sostituisce DIME & WS-AttachmentsBenefici

Componibile con WS-Security per proteggere anche i dati come il SOAP messageModello di programmazione semplificato e attivazione via config

Riduzione sul cavo della dimensione del messaggio

SecuritySecurity

SemplificaSemplifica

RiduzioneRiduzione

[WebMethod]public byte[ ] GetFileAsBytes (string fileName) { return CreateFileAsBytesResponse (fileName); }

Page 45: Costruire Web Service oggi e domani Giuseppe Guerrasio Architect, Microsoft

WSE 3.0: La strada verso WCF(Indigo)

Grantita l’interoperabilità on the wire level con WCFSupporto per gli scenari di sicurezza interoperabili

WSE turnkey security assertion allineati con WCF security binding

WSE 3.0 si esegue side-by- side con Indigo

Guide per l’upgrade fornite per la migrazione da WSE 3.0 a WCF