Export (0) Print
Expand All

Implementing Endpoints

An endpoint is a service that can listen natively for requests. SMO supports various types of endpoints by using the Endpoint object. You can create an endpoint service that handles a specific type of payload, which uses a specific protocol, by creating an instance of an Endpoint object and setting its properties.

The EndpointType property of the Endpoint object can be used to specify on of the following payload types:

  • Database mirroring

  • SOAP

  • Service Broker

  • Transact-SQL

Also, the ProtocolType property can be used to specify the following two supported protocols:

  • HTTP protocol

  • TCP protocol

Having specified the type of payload, the actual payload can be set by using the Payload object property. The Payload object property provides a reference to a payload object of the specified type, for which the properties can be modified.

For the DatabaseMirroringPayload object, you must specify the mirroring role and whether encryption is enabled. The ServiceBrokerPayload object requires information about message forwarding, maximum number of connections allowed and the authentication mode. The SoapPayloadMethod object requires various properties to be set including the Add object property that specifies the SOAP payload methods available to clients (stored procedures and user-defined functions).

Similarly, the actual protocol can be set by using the Protocol object property that references a protocol object of the type specified by ProtocolType property. The HttpProtocol object requires a list of restricted IP addresses, and port, website, and authentication information. The TcpProtocol object also requires a list of restricted IP addresses and port information.

When the endpoint has been created and fully defined, access can be granted to, revoked from, and denied to database users, groups, roles, and logons.

For the following code example, you will have to select the programming environment, programming template and the programming language to create your application. For more information, see How to: Create a Visual Basic SMO Project in Visual Studio .NET and How to: Create a Visual C# SMO Project in Visual Studio .NET.

The code example demonstrates how to create a Database Mirroring endpoint in SMO. This is necessary before you create a database mirror. Use the IsMirroringEnabled and other properties on the Database object to create a database mirror.

'Set up a database mirroring endpoint on the server before setting up a database mirror.
'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Define an Endpoint object variable for database mirroring.
Dim ep As Endpoint
ep = New Endpoint(srv, "Mirroring_Endpoint")
ep.ProtocolType = ProtocolType.Tcp
ep.EndpointType = EndpointType.DatabaseMirroring
'Specify the protocol ports.
ep.Protocol.Http.SslPort = 5024
ep.Protocol.Tcp.ListenerPort = 6666
'Specify the role of the payload.
ep.Payload.DatabaseMirroring.ServerMirroringRole = ServerMirroringRole.All
'Create the endpoint on the instance of SQL Server.
ep.Create()
'Start the endpoint.
ep.Start()
Console.WriteLine(ep.EndpointState)


The code example demonstrates how to create a Database Mirroring endpoint in SMO. This is necessary before you create a database mirror. Use the IsMirroringEnabled and other properties on the Database object to create a database mirror.

//Set up a database mirroring endpoint on the server before 
//setting up a database mirror. 
//Connect to the local, default instance of SQL Server. 
{ 
   Server srv = default(Server); 
   srv = new Server(); 
   //Define an Endpoint object variable for database mirroring. 
   Endpoint ep = default(Endpoint); 
   ep = new Endpoint(srv, "Mirroring_Endpoint"); 
   ep.ProtocolType = ProtocolType.Tcp; 
   ep.EndpointType = EndpointType.DatabaseMirroring; 
   //Specify the protocol ports. 
   ep.Protocol.Http.SslPort = 5024; 
   ep.Protocol.Tcp.ListenerPort = 6666; 
   //Specify the role of the payload. 
   ep.Payload.DatabaseMirroring.ServerMirroringRole = ServerMirroringRole.All; 
   //Create the endpoint on the instance of SQL Server. 
   ep.Create(); 
   //Start the endpoint. 
   ep.Start(); 
   Console.WriteLine(ep.EndpointState); 
} 
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft