SQL server 2005中如何建立HTTP的端点
建立一个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帮助
下面这个例子显示如何通过JAV来调用端点执行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' );
关键字:SQL server、HTTP、服务器
新文章:
- CentOS7下图形配置网络的方法
- CentOS 7如何添加删除用户
- 如何解决centos7双系统后丢失windows启动项
- CentOS单网卡如何批量添加不同IP段
- CentOS下iconv命令的介绍
- Centos7 SSH密钥登陆及密码密钥双重验证详解
- CentOS 7.1添加删除用户的方法
- CentOS查找/扫描局域网打印机IP讲解
- CentOS7使用hostapd实现无AP模式的详解
- su命令不能切换root的解决方法
- 解决VMware下CentOS7网络重启出错
- 解决Centos7双系统后丢失windows启动项
- CentOS下如何避免文件覆盖
- CentOS7和CentOS6系统有什么不同呢
- Centos 6.6默认iptable规则详解