-- This is on the main instance
-- 

IF EXISTS
  (SELECT * FROM sys.databases WHERE name = 'BrokerDB1')
DROP DATABASE BrokerDB1
go

CREATE DATABASE BrokerDB1
GO

USE BrokerDB1
GO

--
-- Step 1: create the initiator side
--

-- Message Types And Contracts Go On Both Sides

-- Step 1: Create the initiator side
-- Message Types And Contracts Go On Both Sides

-- define two message types with XML validation
CREATE MESSAGE TYPE InvRequestMsg 
VALIDATION = WELL_FORMED_XML
GO

CREATE MESSAGE TYPE InvResponseMsg
VALIDATION = WELL_FORMED_XML
GO

-- define a contract between the two sides
CREATE CONTRACT InvContract
 (InvRequestMsg SENT BY INITIATOR,
  InvResponseMsg SENT BY TARGET)
GO

-- create queues and services
CREATE QUEUE InvResponseQueue
GO

CREATE SERVICE InvInitiator
 ON QUEUE InvResponseQueue
 (InvContract)
GO

---
--- Security portion
--- Create master key.
---
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'StrongPW1'
GO

---
--- End of Step 1:
--- Next create objects on the target
--- 


