HTTP endpoints in SQL2005

Source: Internet
Author: User
Sql2005 SQL2005 provides a new way to execute stored procedures or T-SQL, which can be published to the server as a Web service without the use of IIS

This new feature exposes the HTTP endpoint to the user via the HTTP API, and it is very simple to support the creation of an HTTP endpoint on WinXP SP2 and WIN2003, as follows

CREATE ENDPOINT myendpoint?
State = Started
As HTTP (
Authentication = (Integrated),
PATH = '/sql/myendpoint ',
PORTS = (Clear))
For SOAP (
Batches = ENABLED,
WSDL = DEFAULT
)
In the case above I created an endpoint named Myendpoint, which listens to T-SQL statements in Http://localhost/sql/myendpoint, and you can test it using the following URL
Http://localhost/sql/myendpoint?wsdl.
The above URL can also be attached to a rich parameter, specifically see SQL Help
The following example shows how to call an endpoint to execute a T-SQL statement through Javscript, as follows
function Sendbatchrequest (strServerName, Strurlpath, strquery)
{
var objxmlhttp = null;
var strrequest = "";

objXmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
Objxmlhttp.open ("POST", "http://" + strServerName + Strurlpath, false);
Objxmlhttp.setrequestheader ("Content-type", "Text/xml");
Objxmlhttp.setrequestheader ("Host", strservername);

Strrequest = "<soap-env:envelope
xmlns:soap-env= ' http://schemas.xmlsoap.org/soap/envelope/'
Xmlns:sql= ' Http://schemas.microsoft.com/sqlserver/2004/SOAP ' >
<SOAP-ENV:Body>
<sql:sqlbatch>
<sql:BatchCommands> "+ strquery +" </sql:BatchCommands>
</sql:sqlbatch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> ";

Objxmlhttp.send (strrequest);

if (Objxmlhttp.status = 200)
return objXmlHttp.responseXML.xml;
Else
Return "";
}

var response = sendbatchrequest (' localhost ', '/sql/myendpoint ', ' Select * from sys.http_endpoints ');



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.