
USE BrokerDB1
GO


DECLARE @h UNIQUEIDENTIFIER;
DECLARE @invreq XML;
SET @invreq = '
<InvRequest>
  <Product>1234</Product>
  <Quantity>6</Quantity>
</InvRequest>'

BEGIN TRANSACTION;
-- ENCRYPTION ON
BEGIN DIALOG CONVERSATION @h
 FROM SERVICE InvInitiator
 TO SERVICE 'InvService'
 ON CONTRACT InvContract;

-- 1 request for product 1234
SEND ON CONVERSATION @h 
 MESSAGE TYPE InvRequestMsg (@invreq);
COMMIT;
GO

---
--- Step 5: Read response - as a low privilege user
---

DECLARE @h UNIQUEIDENTIFIER;
DECLARE @resp XML;

BEGIN TRANSACTION;
RECEIVE TOP(1)
 @resp = CAST(message_body AS XML),
 @h = conversation_handle
 FROM InvResponseQueue;
PRINT CONVERT(VARCHAR(10),@resp);
-- You don't need to read the end conversation message
-- You can decide to unconditionally end the conversation
END CONVERSATION @h
COMMIT;
GO