Utilizzo dell'applicazione WSDL personalizzata
Questa caratteristica verrà rimossa a partire da una delle prossime versioni di Microsoft SQL Server. Evitare di utilizzare questa caratteristica in un nuovo progetto di sviluppo e prevedere interventi di modifica nelle applicazioni in cui è attualmente implementata.
Per configurare l'applicazione di esempio del generatore WSDL personalizzato, è necessario eseguire le operazioni seguenti:
Creare un'applicazione di gestione WSDL personalizzata per supportare il file WSDL specifico.
Per eseguire questa operazione, vedere Creazione dell'applicazione WSDL personalizzata.
Configurare l'installazione di SQL Server per registrare e utilizzare il gestore WSDL personalizzato.
Questa operazione comporta la creazione di uno script di distribuzione che apporta le modiche seguenti all'installazione di SQL Server:
Aggiunge l'assembly WSDL personalizzato (CustomWSDL.dll) al server e lo registra per l'utilizzo con l'istruzione ADD ASSEMBLY.
Crea eventuali stored procedure aggiuntive da cui dipende il corretto funzionamento dell'applicazione del gestore WSDL personalizzata.
Crea o modifica un endpoint HTTP in corrispondenza dell'istanza di SQL Server in modo che utilizzi il gestore WSDL personalizzato e restituisca una risposta WSDL personalizzata, anziché la risposta WSDL predefinita o semplice.
Distribuzione del gestore WSDL personalizzato
Nella procedura seguente si presuppone che sia stato eseguito l'accesso come amministratore a un computer in cui è in esecuzione SQL Server oppure che sia possibile connettersi al computer in remoto con privilegi amministrativi.
Parte 1: Configurazione del server
In SQL Server Management Studio fare clic su Nuova query e quindi connettersi al server.
Copiare lo script Transact-SQL seguente nella finestra Query.
USE master GO -- Drop myWSDL procedure if it exists. IF (SELECT count(*) FROM sysobjects WHERE name = 'myWSDL') = 1 DROP PROCEDURE myWSDL GO -- Drop CustomWSDL assembly if it exists. DROP ASSEMBLY CustomWSDL GO -- Update the path to the compiled assembly as necessary. CREATE ASSEMBLY CustomWSDL FROM 'C:\temp\CustomWSDL.dll' GO -- Create a stored procedure to map to the common lanugage -- runtime (CLR) method As with any other SQL Server stored procedure -- that maps to a CLR method, the actual stored procedure name -- ('myWSDL') can be arbitrarily specified. CREATE PROCEDURE myWSDL ( @endpointID as int, @isSSL as bit, @host as nvarchar(256), @queryString as nvarchar(256), @userAgent as nvarchar(256) ) AS EXTERNAL NAME CustomWSDL.[MSSql.CustomWSDL].GenerateWSDL GO -- Follow the security guidelines set up for your environment. -- The following example is meant to be used for development or -- testing purposes only. GRANT EXEC on myWSDL to [PUBLIC] GO -- The following is a sample stored procedure (InOut) that -- demonstrates the configuration of an HTTP endpoint. -- If the InOut stored procedure already exists, it is dropped. IF (SELECT count(*) FROM sysobjects WHERE name = 'InOut') = 1 DROP PROC InOut GO CREATE PROC InOut @InParam int, @OutParam nvarchar(100) output AS SELECT * FROM syslanguages WHERE langid = @InParam SELECT @OutParam = [name] FROM syslanguages WHERE langid = @InParam PRINT @OutParam SELECT * FROM syslanguages WHERE langid = @InParam FOR XML raw, XMLSCHEMA RETURN 1 GO GRANT EXEC on InOut to [PUBLIC] -- The following creates a sample HTTP endpoint to demonstrate -- the endpoint setup. If the sample endpoint already exists, it -- is first dropped. IF (SELECT count(*) FROM [msdb].sys.http_endpoints WHERE name = 'sql_endpoint') = 1 DROP ENDPOINT sql_endpoint GO CREATE ENDPOINT sql_endpoint STATE=STARTED AS HTTP ( SITE='*', PATH='/sql/WSDL', PORTS=(CLEAR), CLEAR_PORT=80, AUTHENTICATION=(DIGEST, INTEGRATED) ) FOR SOAP ( WEBMETHOD 'http://myNS.com/'.'InOut' ( NAME='master.dbo.InOut' ), DATABASE = 'master', WSDL='master.dbo.myWSDL', Batches=enabled, SCHEMA = STANDARD ) GRANT CONNECT ON ENDPOINT::sql_endpoint to [PUBLIC]
Eseguire lo script.
Parte 2: Test del gestore
Per verificare il corretto funzionamento del gestore WSDL, provare a utilizzare le stringhe query URL modificate per richiedere un WSDL personalizzato. Se, ad esempio, l'istanza di SQL Server a cui si esegue la connessione è denominata MyServer e si utilizza lo script precedente, deve essere stato definito il percorso di un endpoint nel server di sql/WSDL, che risponderà utilizzando il gestore WSDL personalizzato. Per verificare la connessione all'endpoint e inviare una richiesta WSDL personalizzata, è pertanto necessario utilizzare un URL come il seguente nel client browser Web HTTP:
http://MyServer/sql/WSDL?wsdlargument
Il valore di argument può essere impostato su uno qualsiasi degli identificatori WSDL personalizzati indicati di seguito che supportano le stringhe per ogni client e tipo WSDL diverso.
URL WSDL personalizzato |
Descrizione |
---|---|
everett |
Per client Web semplici sviluppati utilizzando gli strumenti di sviluppo di Visual Studio 2003. |
jbuilder |
Per client Web semplici sviluppati utilizzando gli strumenti di sviluppo di Borland JBuilder 9.0. |
glue |
Per client Web semplici sviluppati utilizzando gli strumenti di sviluppo di webMethods Glue 5.0.1. |
Come illustrato nella tabella seguente, il valore <argument> restituisce un WSDL semplice (tutti i tipi XSD nativi) per tutte e tre le scelte personalizzate. Se, tuttavia, si desidera il formato WSDL esteso, è possibile aggiungere extended alla stringa di argomento della query.
Identificatore WSDL semplice |
Identificatore WSDL esteso |
---|---|
http://MyServer/sql/WSDL?wsdleverett |
http://MyServer/sql/WSDL?wsdleverettextended |
http://MyServer/sql/WSDL?wsdljbuilder |
http://MyServer/sql/WSDL?wsdljbuilderextended |
http://MyServer/sql/WSDL?wsdlglue |
http://MyServer/sql/WSDL?wsdlglueextended |