下面请跟着图老师小编一起来了解下SQL server 2005中如何建立HTTP的端点,精心挑选的内容希望大家喜欢,不要忘记点个赞哦!
【 tulaoshi.com - 编程语言 】
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.
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)上面这个URL还可以附加很丰富的参数,具体参见SQL帮助
下面这个例子显示如何通过JAVSCRIPT来调用端点执行T-SQL语句,如下:
(本文来源于图老师网站,更多请访问http://www.tulaoshi.com/bianchengyuyan/)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' ); 
来源:http://www.tulaoshi.com/n/20160219/1625726.html
看过《SQL server 2005中如何建立HTTP的端点》的人还看了以下文章 更多>>