码迷,mamicode.com
首页 > 数据库 > 详细

sql调用web服务

时间:2018-03-22 19:26:51      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:res   +=   false   esc   nvarchar   control   _id   gpo   obj   

基本存储过程:
/****** Object: StoredProcedure [dbo].[spCallBoService] Script Date: 11/19/2015 16:45:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[spCallBoService]
(
@Url NVARCHAR(MAX) = ‘http://192.168.0.151:8085/BillService.asmx/‘ ,
@MethodName VARCHAR(50) = ‘HelloWorld‘ ,
@Parameters NVARCHAR(MAX) = ‘‘ ,
@result VARCHAR(MAX) OUT
)
AS
DECLARE @obj INT
DECLARE @ValorDeRegreso INT
DECLARE @response VARCHAR(8000)
SET @Url = @Url + @MethodName
IF LEN(@Parameters) > 0
BEGIN
SET @Url += ‘?‘ + @Parameters
END
PRINT @Url
EXEC sp_OACreate ‘MSXML2.XMLHttp‘, @obj OUT
EXEC sys.sp_OAMethod @obj, ‘Open‘, NULL, ‘Get‘, @Url, false
EXEC sp_OAMethod @obj, ‘send‘
EXEC sys.sp_OAGetProperty @obj, ‘responseText‘, @response OUT
SET @result = @response
EXEC sys.sp_OADestroy @obj

 


使用方法:
/****** Object: StoredProcedure [dbo].[sp_CallSynFailureSendMCodeToMticket] Script Date: 11/19/2015 16:48:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- Author: 曾添利
-- Create date: 2015-11-18
-- Description: 定时同步大转盘m券推送券系统失败的m券
-- =============================================
CREATE PROCEDURE [dbo].[sp_CallSynFailureSendMCodeToMticket]
AS
BEGIN
DECLARE @result NVARCHAR(1000)
EXEC dbo.spCallBoService @Url = N‘http://192.168.0.37:8080/WebService.asmx/‘, -- nvarchar(max)
@MethodName = ‘ExecuteControlFunction‘, -- varchar(50)
@Parameters = N‘paramJson=["MyjWeiXin.Controllers.Activity.Roulette.RoulettePage","SynFailureSendMCodeToMticket"]‘, -- nvarchar(max)
@result = @result OUTPUT -- varchar(max)
PRINT @result

END

sql调用web服务

标签:res   +=   false   esc   nvarchar   control   _id   gpo   obj   

原文地址:https://www.cnblogs.com/zengtianli/p/8625300.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!