SQL Tips by Namwar Rizvi

May 12, 2007

Using Stored Procedure as a Web Service in SQL Server 2005

Filed under: New Features,SQL Server 2005,tips,Web Services — namwar @ 5:43 PM

Web Services are getting more and more popular these days. SQL Server 2005 provides an excellent set of features to expose stored procedures as web services. Following is a quick and easy way to implement a stored procedure as a web service. It is just an example but gives you a clear idea how to use SQL Server 2005 for web service implementation:

Set ANSI_NULLS ON
Set QUOTED_IDENTIFIER ON
go

—Sample STored procedure to retrieve Server Date and Time
Create Proc usp_GetServerTime
as
Select GetDate()

—Creating Web Service
CREATE ENDPOINT [EP_GetServerTime]
STATE=STARTED
AS HTTP
(
PATH=‘/URL_GetServerTime’,
PORTS = (CLEAR),
AUTHENTICATION = (INTEGRATED),
SITE=‘DBSERVER’
)
FOR SOAP
(
WEBMETHOD ‘GetServerTime’
(
NAME=‘TestDB.dbo.usp_GetServerTime’
),
WSDL=DEFAULT,
DATABASE=‘TestDB’,
NAMESPACE=DEFAULT
)

For details on web service support in SQL Server 2005, please visit

http://www.developer.com/db/article.php/3390241

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: