这个新特点通过http api把http端点暴露给用户,在winxp sp2和win2003上被支持建立一个http端点是非常简单的,如下
create endpoint myendpoint?
state = started
as http (
authentication = (integrated),
path = '/sql/myendpoint',
ports = (clear) )
for soap (
batches = enabled,
wsdl = default
)
在上面的案例中我建立一个命名为myendpoint的端点,它在http://localhost/sql/myendpoint监听t-sql语句,你可以使用下面url测试它
http://localhost/sql/myendpoint?wsdl.
上面这个url还可以附加很丰富的参数,具体参见sql帮助
下面这个例子显示如何通过javscript来调用端点执行t-sql语句,如下
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' );
新闻热点
疑难解答