Udostępnij za pośrednictwem


Lesson 3: Creating the Initiator Conversation Objects

New: 15 September 2007

In this lesson, you will learn to build all the objects that enable a database to initiate a conversation with another database.

Procedures

Switch to the InitiatorDB database

  1. Copy and paste the following code into a Query Editor window. Then, run it to switch context to the InitiatorDB database.

    USE InitiatorDB;
    GO
    

Create the message types

  1. Copy and paste the following code into a Query Editor window. Then, run it to create the message types for the conversation. The message type names and properties that are specified here must be identical to the ones that were created in the TargetDB in the previous lesson.

    CREATE MESSAGE TYPE [//BothDB/2DBSample/RequestMessage]
           VALIDATION = WELL_FORMED_XML;
    CREATE MESSAGE TYPE [//BothDB/2DBSample/ReplyMessage]
           VALIDATION = WELL_FORMED_XML;
    GO
    

Create the contract

  1. Copy and paste the following code into a Query Editor window. Then, run it to create the contract for the conversation. The contract name and properties that are specified here must be identical to the contract that was created in the TargetDB in the previous lesson.

    CREATE CONTRACT [//BothDB/2DBSample/SimpleContract]
          ([//BothDB/2DBSample/RequestMessage]
             SENT BY INITIATOR,
           [//BothDB/2DBSample/ReplyMessage]
             SENT BY TARGET
          );
    GO
    

Create the initiator queue and service

  1. Copy and paste the following code into a Query Editor window. Then, run it to create the queue and service that is used for the initiator. Because no contract name is specified, no other services can use this service as a target service.

    CREATE QUEUE InitiatorQueue2DB;
    
    CREATE SERVICE [//InitDB/2DBSample/InitiatorService]
           ON QUEUE InitiatorQueue2DB;
    GO
    

Next Steps

You have successfully configured the InitiatorDB and TargetDB to support a conversation between the two databases. Next, you will complete a conversation that uses the configuration. See Lesson 4: Beginning a Conversation and Transmitting Messages.

See Also

Other Resources

CREATE MESSAGE TYPE (Transact-SQL)
CREATE CONTRACT (Transact-SQL)
CREATE QUEUE (Transact-SQL)
CREATE SERVICE (Transact-SQL)
Conversation Architecture
Service Architecture

Help and Information

Getting SQL Server 2005 Assistance