Call Web Service from SQL Server(从 SQL Server 调用 Web 服务)
问题描述
我有一个带有 Web 方法的 Web 服务,该方法可以响应您传递的任何内容.
I have a web service with a web method which echoes whatever you pass it.
我尝试从 T-SQL 代码调用我的 Web 方法,但它既不工作也不产生任何异常或错误.
I try to call my web method from T-SQL code but it neither works nor yields any exception or error.
代码如下:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Exec sp_OACreate 'MSXML2.ServerXMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get',
'http://vserver250:8600/EcomSmsSvc.asmx/Reply?message=hi','false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Select @ResponseText
Exec sp_OADestroy @Object
我的网络服务工作正常,当我通过网络浏览器调用它时,它返回我发送的消息,但是当我从 T-SQL 调用它时,结果总是 NULL.
My web service works fine, and when I call it through web browsers it returns the message I send it, but when I call it from T-SQL the result is always NULL.
谁能帮我找出问题所在?
Can anyone help me find out where the problem is?
推荐答案
我建议使用 内置于 .NET 的网络服务客户端.我想这将是一个更简洁的解决方案,更易于维护且更易于测试和调试.
I would suggest to do it using a web service client built in .NET. I suppose this would be a cleaner solution, more maintainable and easier to test and debug.
在这篇文章中你可以找到这样一个例子.
In this post you could find such an example.
希望我有所帮助!
这篇关于从 SQL Server 调用 Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 SQL Server 调用 Web 服务
基础教程推荐
- 什么是 orradiag_<user>文件夹? 2022-01-01
- 二进制文件到 SQL 数据库 Apache Camel 2021-01-01
- 如何根据该 XML 中的值更新 SQL 中的 XML 2021-01-01
- 在多列上分布任意行 2021-01-01
- 表 './mysql/proc' 被标记为崩溃,应该修复 2022-01-01
- oracle区分大小写的原因? 2021-01-01
- MySQL 中的类型:BigInt(20) 与 Int(20) 2021-01-01
- mysql选择动态行值作为列名,另一列作为值 2021-01-01
- 如何在 SQL 中将 Float 转换为 Varchar 2021-01-01
- 在 MySQL 中:如何将表名作为存储过程和/或函数参数传递? 2021-01-01
