For this demonstration we will use service broker construction created in another part of this documentation. Mentioned part is named 3. Create basic service broker construction on database (single database communication).
USE [MyDatabase]
DECLARE @ch uniqueidentifier = NEWID()
DECLARE @msg XML
BEGIN DIALOG CONVERSATION @ch
FROM SERVICE [InitiatorService]
TO SERVICE 'TargetService'
ON CONTRACT [//call/contract]
WITH ENCRYPTION = OFF; -- more possible options
SET @msg = (
SELECT 'HelloThere' "elementNum1"
FOR XML PATH(''), ROOT('ExampleRoot'), ELEMENTS XSINIL, TYPE
);
SEND ON CONVERSATION @ch MESSAGE TYPE [//initiator] (@msg);
END CONVERSATION @ch;
After this conversation will be your msg in TargetQueue