代码:
DECLARE @Object as Int
Exec sp_OACreate 'WinHttp.WinHttpRequest.5.1', @Object OUT;
DECLARE @LoginResultType INT
declare @ServiceUrl as varchar(1000)
set @ServiceUrl = 'http://192.168.1.233/k3cloud/Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc'
DECLARE @data varchar(max);
set @data='{"acctID": "66a4611abce743","username": "T1","password": "T1.3333322","lcid": 2052}'
Declare @ResponseText AS varchar(8000);
Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false'
Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','application/json;charset=UTF-8'
Exec sp_OAMethod @Object, 'send', NULL, @data
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
SET @LoginResultType=JSON_VALUE(@ResponseText,'$.LoginResultType')
SELECT '用户验证消息:'+@ResponseText
IF @LoginResultType=1
BEGIN
SET @data='{"formId":"PRD_MO","opNumber":"UnAudit","data":{"Numbers":"MO_2408050007"}}'
SET @ServiceUrl='http://192.168.1.233/k3cloud/Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.ExcuteOperation.common.kdsvc' Exec sp_OAMethod @Object, 'open', NULL, 'POST',@ServiceUrl,'false'
Exec sp_OAMethod @Object, 'setRequestHeader', NULL, 'Content-Type','application/json;charset=UTF-8'
Exec sp_OAMethod @Object, 'send', NULL, @data
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Exec sp_OADestroy @Object
SELECT @ResponseText
END