我有一个带有 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 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!