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規則詳解