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 ');