我尝试调用Web服务从SQL Server获取数据。
如何将该SOAPUI请求传输到从sql-server启动的请求,例如像http://harshilnshah.blogspot.com/2013/03/call-webservice-from-stored-procedure.html
通过使用SOAPUI ist来生成请求!
请求(正在使用SOAPUI生成):
GET https://one.server.com/api/export?count=2500&skip=0 HTTP/1.1
Accept-Encoding: gzip,deflate
Authorization: auth dVh4NmpBSFhpT01YMnRtWlhMd2d6
companyId: f5fbb815-51515
Host: one.server.com
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
从网络服务器(JSON)(SOAPUI)返回数据:
{
"TotalResults": 10,
"StartIndex": 0,
"Count": 50,
"List": [
{
"Email": "email1@email.com",
"FirstName": "Werner",
"LastName": "Maier",
"DisplayName": "Werner Maier",
"Language": "de",
"TimeZone": "W. Europe Standard Time",
"Theme": null,
"Groups": "admin,HR"
},
...
感谢和问候!
我尝试过:
-- Enable Ole Automation
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
sp_configure 'show advanced options', 0;
GO
RECONFIGURE;
GO
BEGIN
SET NOCOUNT ON;
DECLARE @Object INT;
DECLARE @Status INT;
DECLARE @requestBody NVARCHAR(MAX) = '{
"companyId": "f5fbb815-51515",
"Authorization": "auth dVh4NmpBSFhpT01YMnRtWlhMd2d6"
}'
EXEC sp_OACreate 'WinHttp.WinHttpRequest.5.1', @Object OUT;
EXEC sp_OAMethod @Object, 'Open', NULL, 'GET', 'https://one.server.com/api/export?count=2500&skip=0', 'false'
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json'
DECLARE @len INT = len(@requestBody)
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Length', @len
EXEC sp_OAMethod @Object, 'send', null, @requestBody
EXEC sp_OAGetProperty @Object, 'Status', @Status OUT
EXEC sp_OADestroy @Object
END
-- Enable Ole Automation
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
sp_configure 'show advanced options', 0;
GO
RECONFIGURE;
GO
BEGIN
SET NOCOUNT ON;
DECLARE @Object INT;
DECLARE @Status INT;
DECLARE @requestBody NVARCHAR(MAX) = '{
"companyId": "f5fbb815-51515",
"Authorization": "auth dVh4NmpBSFhpT01YMnRtWlhMd2d6"
}'
EXEC sp_OACreate 'WinHttp.WinHttpRequest.5.1', @Object OUT;
EXEC sp_OAMethod @Object, 'Open', NULL, 'GET', 'https://one.server.com/api/export?count=2500&skip=0', 'false'
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Type', 'application/json'
DECLARE @len INT = len(@requestBody)
EXEC sp_OAMethod @Object, 'setRequestHeader', null, 'Content-Length', @len
EXEC sp_OAMethod @Object, 'send', null, @requestBody
EXEC sp_OAGetProperty @Object, 'Status', @Status OUT
EXEC sp_OADestroy @Object
END