我对SQL Server有一个奇怪的问题。我有一个小的触发器,可以在更新时向Web服务发出请求。
我已经测试过该代码,它工作正常。
但是,当我将该代码移动到另一台SQL Server计算机时,它不会运行。没有错误。
更新:如果我打电话给" Get"请求,没关系。用" Post"请求,SQL Server无法处理它。两台服务器都在Windows 2012上运行
我的呼叫请求代码:
DECLARE @dbName NVARCHAR(50)
DECLARE @wsAction NVARCHAR(50)
DECLARE @secret NVARCHAR(255)
DECLARE @url NVARCHAR(MAX)
DECLARE @idArray NVARCHAR(MAX)
DECLARE @triggerTime DATETIME
SET @dbName = 'dbname' + '/notification/object'
SET @secret = 'a key'
SET @url = 'https://myserver/api/1.0.0/customer/databaseName='
SET @idArray = '1,2,3'
SET @wsAction = '"action": "modify"'
IF(@idArray <> '')
BEGIN
DECLARE @Object INT;
DECLARE @body NVARCHAR(MAX)
SET @url = @url + @dbName;
SET @body = '{"ids": [' + @idArray + '], ' + @wsAction +'}'
EXEC sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
EXEC sp_OAMethod @Object, 'setOption', null, 2, 13056 -- by pass ssl
EXEC sp_OAMethod @Object, 'open', NULL, 'post', @url,'false'
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'secret', @secret
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Accept-Encoding', 'gzip, deflate'
EXEC sp_OAMethod @Object, 'send', NULL, @body
Declare @ResponseText as Varchar(8000);
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Select @ResponseText
EXEC sp_OADestroy @Object
END
&#34; GET&#34;请求我测试:
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get',
'http://www.webservicex.com/stockquote.asmx/GetQuote?symbol=MSFT', --Your Web Service Url (invoked)
'false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Select @ResponseText
Exec sp_OADestroy @Object
答案 0 :(得分:0)
我发现了问题 “msxml3.dll”的已知错误: https://support.microsoft.com/en-us/kb/2968741 这个链接帮助我很多: http://www.sqlservercentral.com/scripts/Miscellaneous/30867/ 获取错误信息