Oct 7, 2013

Create EndPoint in SQL Server

In previous article, we learnt What is endpoint in SQL Server

In this article, we would learn how to create an Endpoint in SQL Server

Before creating an endpoint, we need to reserve an HTTP Namespace to expose the endpoint.

EXEC sp_reserve_http_namespace N'http://localhost:80/sql'

While creating endpoint you might face the below error




See how to resolve this error:
Msg 6004, Level 16, State 12, Line 1 User does not have permission to perform this action.

Reserved HTTP Namespace can be deleting using below command

sp_reserve_http_namespace N'https://localhost:80/sql'
Let's First create a function which we would expose using the endpoint


Create Function fn_EndPoint()
Returns Varchar(100)
AS
Begin
    Return 'My End Point'
End

Now lets create an endpoint that would expose the function "fn_EndPoint" that we created above.

Create Endpoint MyEndpoint
STATE = STARTED
AS HTTP
(                                 
    path='/sql/',
    AUTHENTICATION=(INTEGRATED),
    PORTS=(CLEAR),
    SITE ='localhost'
)
FOR SOAP
(             
    WEBMETHOD 'http://localhost/'.'GetEndPoint'         
   (     
        name='DatabaseName.dbo.fn_EndPoint',
        SCHEMA = STANDARD
    ),   
    WSDL = DEFAULT,
    BATCHES=DISABLED,
    DATABASE='DatabaseName'
)

In the next article, we will see how to start or stop endpoint in SQL Server

    Choose :
  • OR
  • To comment
1 comment:
Write Comments