USE master;
GO
CREATE DATABASE InstInitiatorDB;
GO
USE InstInitiatorDB;
GO
CREATE MASTER KEY
ENCRYPTION BY PASSWORD = N'kirito';
GO
CREATE USER InitiatorUser WITHOUT LOGIN;
GO
CREATE CERTIFICATE InstInitiatorCertificate
AUTHORIZATION InitiatorUser
WITH SUBJECT = N'Initiator Certificate',
EXPIRY_DATE = N'12/31/2099';
GO
BACKUP CERTIFICATE InstInitiatorCertificate
TO FILE = N'C:\ssd_shared\tmp\InstInitiatorCertificate.cer';
GO
CREATE MESSAGE TYPE [//BothDB/2InstSample/RequestMessage]
VALIDATION = WELL_FORMED_XML;
CREATE MESSAGE TYPE [//BothDB/2InstSample/ReplyMessage]
VALIDATION = WELL_FORMED_XML;
GO
CREATE CONTRACT [//BothDB/2InstSample/SimpleContract]
([//BothDB/2InstSample/RequestMessage]
SENT BY INITIATOR,
[//BothDB/2InstSample/ReplyMessage]
SENT BY TARGET
);
GO
CREATE QUEUE InstInitiatorQueue;
--drop service [//InstDB/2InstSample/InitiatorService]
CREATE SERVICE [//InstDB/2InstSample/InitiatorService]
AUTHORIZATION InitiatorUser
ON QUEUE InstInitiatorQueue
([//BothDB/2InstSample/SimpleContract]);
GO
CREATE USER TargetUser WITHOUT LOGIN;
GO
--drop certificate InstTargetCertificate
CREATE CERTIFICATE InstTargetCertificate
AUTHORIZATION TargetUser
FROM FILE = N'C:\ssd_shared\tmp\InstTargetCertificate.cer'
GO
--select * from sys.certificates
USE InstInitiatorDB;
CREATE ROUTE InstTargetRoute
WITH SERVICE_NAME =
N'//TgtDB/2InstSample/TargetService',
ADDRESS = N'TCP://192.168.2.150:4022';
GO
USE msdb;
CREATE ROUTE InstInitiatorRoute
WITH SERVICE_NAME =
N'//InstDB/2InstSample/InitiatorService',
ADDRESS = N'LOCAL';
GO
USE InstInitiatorDB;
CREATE REMOTE SERVICE BINDING TargetBinding
TO SERVICE
N'//TgtDB/2InstSample/TargetService'
WITH USER = TargetUser;
GO
GRANT SEND ON SERVICE::[//InstDB/2InstSample/InitiatorService] to TargetUser