标题: SQL server 2005中如何建立HTTP的端点
ljjk5
元帅
Rank: 1


荣誉会员奖章
UID 46706
精华 1
积分 99426
帖子 49691
威望 554
金币 48489
热心 505
阅读权限 100
注册 2007-2-25
状态 离线
SQL server 2005中如何建立HTTP的端点

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

网友 ljjk5 签名 - 网友社区 ===
顶部
[广告] 免费域名(Free Subdomain) 免费空间(Free hosting) PR查询(Google Pagerank)



当前时区 GMT+8, 现在时间是 2008-10-7 01:45
信产部ICP备案:京ICP备05066424号 北京市公安局网监备案:1101050648号

Powered by Discuz! 5.5.0
清除 Cookies - 联系我们 - 网友俱乐部 - Archiver - WAP