?
Solved

Connect to a domain URL from within SQL Server

Posted on 2016-08-03
3
Medium Priority
?
92 Views
Last Modified: 2016-09-05
Hi,

I have a stored procedure in SQL Server that is connecting to a URL and parsing xml into tables. The URL is on a network that I can access via a VPN connection, but instead of connecting the computer to the network can you just login using SQL Server or tsql.

This is the command:

exec dbo.meteobridgeDavisVantagePro2 @url = 'http://***.***.***.***//cgi-bin/livedataxml.cgi'
      ,@http_basic_username = '****'
      ,@http_basic_password = '********'

The username and password is used to access the URL itself not the domain network too.

This is how I connect to the URL from within the stored procedure:

exec @ole_result = sp_OACreate 'MSXML2.XMLHttp', @ole_object OUT
      exec @ole_result = sp_OAMethod @ole_object, 'open', NULL, 'GET', @url, false, @http_basic_username, @http_basic_password
      exec @ole_result = sp_OAMethod @ole_object, 'send', NULL, ''
      exec @ole_result = sp_OAGetProperty @ole_object, 'status', @http_status OUT
      exec @ole_result = sp_OAGetProperty @ole_object, 'responseXML.xml', @http_response OUT
      SET @xml = @http_response

Thank you
0
Comment
Question by:crompnk
3 Comments
 
LVL 17

Accepted Solution

by:
Barry Cunney earned 1000 total points
ID: 41740337
Hi crompnk,
One option may be to set all this up in a SQL Server job with several steps
Step 1 - Powershell job step which uses New-PSDrive to connect to other domain
Step 2 - T-SQL job step which calls your dbo.meteobridgeDavisVantagePro2 stored procedure
0
 
LVL 7

Assisted Solution

by:Manju
Manju earned 1000 total points
ID: 41740911
With JDBC, you can. Please refer to Microsoft site(https://msdn.microsoft.com/en-us/library/ms378428(v=sql.110).aspx) to play with url's
0
 

Author Closing Comment

by:crompnk
ID: 41784352
I actually solved this by just adding external access to the URL, this was easier than trying to control access within SQL Server.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question