The following example creates an endpoint called sql_endpoint, with two methods: GetSqlInfo and DayAsNumber. These are the methods for which a client can send SOAP requests to the endpoint.
For each method, the default for the FORMAT option is ALL_RESULTS. Therefore, the SOAP response for method request will include error messages, warnings, and rowcount information.
Note the following SOAP-specific settings:
-
The
SCHEMA option is set to STANDARD for the endpoint. Therefore, by default, inline schemas are returned in SOAP responses.
-
The
WSDL option is set to DEFAULT. Therefore, if a client requests a WSDL response from this endpoint (http://Server/sql?wsdl), the server generates and returns a WSDL response to the client.
DROP ENDPOINT sql_endpoint;
GO
CREATE ENDPOINT sql_endpoint
STATE = STARTED
AS HTTP(
PATH = '/sql',
AUTHENTICATION = (INTEGRATED ),
PORTS = ( CLEAR ),
SITE = 'SERVER'
)
FOR SOAP (
WEBMETHOD 'GetSqlInfo'
(name='master.dbo.xp_msver',
SCHEMA=STANDARD ),
WEBMETHOD 'DayAsNumber'
(name='master.sys.fn_MSdayasnumber'),
WSDL = DEFAULT,
SCHEMA = STANDARD,
DATABASE = 'master',
NAMESPACE = 'http://tempUri.org/'
);
GO
You can query the catalog view to find the information about the endpoint that you created, as shown in the following examples. You can also do a join of these catalog views to get the data you want.
Query sys.endpoints to retrieve all of endpoint information in the system. This includes, name, ID of the endpoint, ID of the server principal who owns the endpoint, and other properties of the endpoint.
SELECT *
FROM sys.endpoints;
You can query sys.http_endpoints to retrieve detailed endpoint information related to HTTP, such as SITE, URL, AUTHENTICATION mechanism and other HTTP specific information.
SELECT *
FROM sys.http_endpoints;
To retrieve SOAP-specific information about the endpoint, query sys.soap_endpoints.
SELECT *
FROM sys.soap_endpoints;
To retrieve the SOAP methods that are defined on the endpoint, query sys.endpoint_webmethods.
SELECT *
FROM sys.endpoint_webmethods;
The following example creates a database mirroring endpoint. The endpoint uses port number 7022, although any available port number would work. The endpoint is configured to use Windows Authentication using only Kerberos. The ENCRYPTION option is configured to the nondefault value of SUPPORTED to support encrypted or unencrypted data. The endpoint is being configured to support both the partner and witness roles.
CREATE ENDPOINT endpoint_mirroring
STATE = STARTED
AS TCP ( LISTENER_PORT = 7022 )
FOR DATABASE_MIRRORING (
AUTHENTICATION = WINDOWS KERBEROS,
ENCRYPTION = SUPPORTED,
ROLE=ALL);
GO
When creating a SOAP endpoint on a Windows Server beginning with Windows Server 2003, if the path (URL) and port combination is in use by IIS, CREATE ENDPOINT will fail.
On Windows XP, you might need to stop IIS for the SOAP endpoints to work.
CREATE ENDPOINT sql_endpoint
STATE = STARTED
AS HTTP
( PATH = '/sql',
AUTHENTICATION = (INTEGRATED ),
PORTS = ( CLEAR ),
SITE = 'SERVER',
CLEAR_PORT = 2000 )
FOR SOAP
( WEBMETHOD 'GetSqlInfo' (name='master.dbo.xp_msver', SCHEMA=STANDARD ),
WEBMETHOD 'DayAsNumber' (name='master.sys.fn_MSdayasnumber'),
WSDL = DEFAULT,
SCHEMA = STANDARD,
DATABASE = 'master',
NAMESPACE = 'http://tempUri.org/' );