Przykładowy skrypt usługa
To Transact-SQL Przykładowy kod Określa usługa, która archiwa bez typu dokumentów XML. Znajdują się dwa skrypty: the skrypt kontrakt and the skrypt definicji usługa.Skrypt kontrakt definiuje typy wiadomości i kontrakt usługa.typ komunikatu Definicji i definicji kontrakt powinna odpowiadać inicjujący usług i usługa miejsce docelowe.W związku z tym definicje znajdują się w skrypcie definicji oddzielne usługa, które mogą być rozprowadzane do bazy danych, które obsługuje usługa inicjujący.Skrypt definicji usługa definiuje samej usługa.Ten skrypt powinien być uruchamiany tylko w bazie danych, który implementuje usługa miejsce docelowe.
Uwaga
Skrypt definicji usługa definiuje usługa miejsce docelowe, ale nie zawiera implementacji usługa.
Skrypt kontrakt
-- The contract script contains definitions that must be
-- present for both the intiating service and the target
-- service.
USE AdventureWorks
GO
-- Create messages for each broker-to-broker
-- communication needed to complete the task.
-- Message for the initiator to send XML
-- to be archived.
CREATE MESSAGE TYPE
[//Adventure-Works.com/messages/ArchiveXML]
VALIDATION = WELL_FORMED_XML ;
GO
-- Message to return event archiving information.
CREATE MESSAGE TYPE
[//Adventure-Works.com/messages/AcknowledgeArchiveXML]
VALIDATION = WELL_FORMED_XML ;
GO
-- Create a service contract to structure
-- an event archiving conversation, using
-- the message types defined above.
CREATE CONTRACT
[//Adventure-Works.com/contracts/ArchiveXML/v1.0]
(
[//Adventure-Works.com/messages/ArchiveXML]
SENT BY INITIATOR,
[//Adventure-Works.com/messages/AcknowledgeArchiveXML]
SENT BY TARGET
) ;
GO
Skrypt definicji usługa
-- This script defines the target service. The
-- objects created by this script are only
-- required in a database that hosts the target
-- service.
USE AdventureWorks ;
GO
-- Create the service queue that will receive
-- messages for conversations that implement
-- the ArchiveXML contract.
CREATE QUEUE ArchiveQueue ;
GO
-- Create the service object that exposes the
-- ArchiveEvents service contract and maps
-- it to the ArchiveQueue service queue.
CREATE SERVICE [//Adventure-Works.com/ArchiveService]
ON QUEUE ArchiveQueue
([//Adventure-Works.com/contracts/ArchiveXML/v1.0]) ;
GO