Technical Training
SQL Server 2005 TrainingNative HTTP Support in SQL Server 2005
Using Native HTTP Support in SQL Server 2005
In this tutorial you will learn about Using Native HTTP Support, Native HTTP Support in SQL Server 2005 and Configuring Native HTTP Support .
Using Native HTTP Support
SQL Server 2005 has the built in capability of delivering fully functional web services. The HTTP endpoint is more than just an extension of XML abilities. It can return row sets, scalar values, messages and errors serialized into XML automatically. The technology utilizes XML, supports sessions, and monitors SOAP connections and other database server connections.
SQL Server 2005 permits user to create stored procedures and add them to a HTTP endpoint to create a web service that is immediately deployable. The syntax for the web service is as under:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CREATE PROCEDURE StudentCourse List ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
AS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SELECT X, LASTNAME X, FIRSTNAME, X COURSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FROM Student. Contact AS X ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
INNER JOIN CourseMaster AS Y ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ON X.StudentID= Y.StudentID ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORDER BY X.LastName. X.FirstName ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CREATE ENDPO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Once this is done, a reference can be added to the web service in C# project and it can be used. The syntax for adding the reference is
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Private void btnStuList_Click(object sender, systems.EventArgs e) ;;;;;;
{ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Win2k301_Stu.Course proxy= new win2k301_stu.Course(); ;;;;;;;;;;;;;;;;;;
Proxy.Credentials=System.Net.CredentialCache.DefaultCredentials; ;;;;;;;
Object[] stu=proxy.StudentCourseList(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DataSet reulttDs=(DataSet) stu[0]; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DataTable dt=resulttds.Tables[0]; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dgvStuList.Datasource=dt; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
dgvStuList.Refresh(); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
The above web service now has to be consumed. This can be done by using the two methods defined for the purpose. The first of these is the HTML page that uses the Microsoft XML core service and client side JavaScript; the next one is the Winforms-based solution in C#.
Creating the HTML document
This HTML page is required for displaying the results requested from the web service. The syntax could be as under:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
< html:html xmlns:html= “http://www.w3.org/1999/xhtml&rdquo" target="_blank" rel="nofollow"; > ;;;;;;;;;;;;;;;
< script > < / script > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;
< body > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;
StudentID: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;
< input type=”text”value= “1”id= “ID” > ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;
< input type= “button” onclick= “GetCourse()”value= “GET” > ;;;;;;; ;;;;
< div id= “divResult” > < / div > ;;;;;;; ;;;; ;;;;;;; ;;;; ;;;;;;; ;;;;
< xml id= “XSL” src= “CourseDescription.xsl” > < / xml > ;;;;;;; ;;;; ;;
< / body > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;
< / html:html > ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In this instance inputs on the ID is received and the web service is called using the button “Get”. This button calls the javaScript that does the work.
The results are then obtained by creating a Simple Object Access Protocol(SOAP) message to be sent to the web service. The process begins when the button click calls the “GetCourse()” function. A location of the web service is assigned to a variable. Next the SendMessage function passes in this URL the SOAP message as a string. The SendMessage then creates the HTTP client using the MSXML in the HTTP variable. Then an XML Document object model is created in the request variable. The SoapEnvelope function then uses the SOAP body created to return the SOAP request as XML. This is loaded into the DOM document and sent to the web service. The response is returned back to the original function “GetCourse()”. This pulls the CourseDespcription node and transforms it for display in the div called divResult.
More sophisticated clients can be created using C#. Since this is beyond the scope of this tutorial we shall suffice by saying that SQL Server 2005 has truly made the work of the programmer simpler!
SQL Server 2005 Training
- SQL Server 2005 - Configuring Replication
- SQL Server 2005 Replication Enhancements
- SQL Server 2005 - Mirror Server
- SQL Server 2005 - Introduction to Data Availability
- SQL Server 2005 - Backing up a Database
- SQL Server 2005 - Using Database Snapshots
- SQL Server 2005 - Disaster Recovery
- SQL Server 2005 - Managing Certificates
- SQL Server 2005 - Managing Permissions
- Managing SQL Server 2005 Security
- SQL Server 2005 - Using the Database Tuning Advisor
- SQL Server 2005 - Tuning a Database
- Maintain indexes in a SQL Server 2005 database
- SQL Server 2005 - Defining Indexes
- SQL Server 2005 - Database Backup
- SQL Server 2005 - Populating the Database
- SQL Server 2005 Configuration Manager
- SQL Server 2005 - Using the Sqlcmd Utility
- Using the SQL Management Objects
- Using SQL Sever Management Studio - Part 2
- Using SQL Sever Management Studio - Part 1
- SQL Server 2005 - Using Event Notifications
- SQL Server 2005 - Using DDL Triggers
- SQL Server Monitoring Tools - Server Profiler
- SQL Server 2005 - Testing Troubleshooting
- SQL Server 2005 - Upgrading from earlier versions of SQL Server
- SQL Server 2005 Installation - Maintenance Plan Without Using Wizard
- SQL Server 2005 - Unattended Installations
- SQL Server 2005 Installation - Maintenance Plan Using Wizard
- Installing a Second Copy of SQL Server 2005
- Planning to Install SQL Server 2005
- SQL Server 2005 Installation
- SQL server 2005 Editions
- SQL Server 2005 Architecture Overview
- SQL Server 2005 - Management studio interface Summary Page
- SQL Server 2005 - Server Groups
- SQL Server 2005 - Registered Servers
- SQL Server 2005 Administrative Tools
- Developing Client applications in SQL Server 2005
- SQL Server Management Objects
- NET CLR in SQL Server 2005
- Native HTTP Support in SQL Server 2005
- XML Data Types in SQL Server 2005
- Using XML in SQL Server 2005
- Using Notification Services in SQL Server 2005
- SQL Server 2005 - Service Broker
- Data Manipulation Language (DML) in SQL Server 2005
- T-SQL Enhancements in SQL Server 2005
- Security Features in SQL Server 2005 for the Developer
- SQL Server Architecture and Components
- SQL Server 2005 Management Studio
- Overview of SQL Server 2005 for the Database Developer
- Getting started with SQL Server 2005







