Creating and Launching Endpoints
You use the CREATE ENDPOINT
statement to create an endpoint as shown below:
CREATE ENDPOINT SQLEP_AWPersons
STATE = STARTED
PATH = '/AWpersons',
AUTHENTICATION = (INTEGRATED),
PORTS = (CLEAR),
SITE = 'sqlidw14'
BATCHES = DISABLED,
WSDL = DEFAULT,
DATABASE = 'AdventureWorks',
NAMESPACE = 'http://Adventure-Works/Persons'
The CREATE ENDPOINT
statement has several key components. The STATE
argument is set to STARTED
, which indicates that the endpoint listener is running. Other options included STOPPED
for handling service endpoints. The rest of the code sits in the AS HTTP
clause or the FOR SOAP
clause. AS HTTP
sets HTTP as the transport for the endpoint and includes the following settings:
- PATHSpecifies the URL for the service endpoint, and in this example defaults to the server name and the path specified, e.g. http://yourdemoserver/AWpersons.
- AUTHENTICATIONSpecifies the type of authentication to be used for the service endpoint. A variety of authentication mechanisms are supported, including BASIC, INTEGRATED (uses Windows security), NTLM, and KERBEROS.
- PORTSSpecifies what port type to use. CLEAR or SSL are the supported options, with CLEAR accepting only HTTP requests and SSL requiring HTTPS.
- SITESpecifies the name of the host computer for the endpoint.
The FOR SOAP
clause supports the following arguments:
- WEBMETHODSpecifies the Web method used to send requests via the HTTP SOAP endpoint. You can declare multiple Web methods per endpoint.
- BATCHESSpecifies whether not the endpoint supports ad-hoc SQL requests. This is disabled by default.
- WSDLSpecifies whether the endpoint supports WSDL. For custom WSDL implementations, you can provide a stored procedure name that returns a custom WSDL implementation.
- DATABASESpecifies the name of the database where the requested operation is executed in context.
- NAMESPACESpecifies a namespace for the endpoint.
After creating the endpoint, you can submit an HTTP request to the server to ensure that the endpoint is responding. A simple test is to navigate to http://sqlidw14/awpersons?wsdl
(substitute your own server and endpoint name), which, if the endpoint is responding, will return the WSDL for your exposed service.
To consume the Web service, simply follow the steps for adding a Web reference and invoking a Web service in a standard .NET application. The downloadable sample application
includes a simple application for testing purposes, including the following code to invoke the Web service:
sqlidw14.SQLEP_AWPersons proxy = new
i = Convert.ToInt32(txtID.Text);
proxy.UseDefaultCredentials = true;
results = proxy.PersonInfo(i);
After the Web service returns the results, the sample client application displays the data.