SQL2005提供了一个新的执行存储进程可能T-SQL的要领,它可以以WEB处事的方法宣布随处事器上,而无须行使IIS 这个新特点通过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' ); (编辑:湖南网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|