简体   繁体   中英

How can I debug being unable to call a web service via SQL (OLE Automation)?

I'm calling a web service from SQL. That may sound strange, but nevertheless, that's what I'm doing.

My code can call an online (public) web service (HTTP GET), but when I try to call a service in the same AWS environment (Also HTTP GET), the service doesn't get called, and I get a blank response.

Here's the code that works:

DECLARE @Object as int;
DECLARE @ResponseText as varchar(8000);

DECLARE @URL as varchar(200) = 'https://democraticintelligence.org/home/ping'

EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
EXEC sp_OAMethod @Object, 'open', NULL, 'get',
    @URL, 
    'false'
EXEC sp_OAMethod @Object, 'send'
EXEC sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT

SELECT @ResponseText

When I replace the @URL with a call to my service in AWS, the service doesn't get called, and I get a blank @ResponseText.

What I've tried:

  • Calling the web service from the database server by pasting the URL into Chrome, works fine.
  • Calling the web service from the my PC by pasting the URL into Chrome, works fine.
  • Calling the web service from SQL on my local PC fails.
  • Calling the web service from SQL on the database server in AWS fails.

Any suggestions to help debug this would be appreciated.

I was using an IP address to call the service in AWS, which didn't work. When I changed it to use the host name, then it worked. I don't know why.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM