Solved

Connect to a domain URL from within SQL Server

Posted on 2016-08-03
3
70 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 250 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 6

Assisted Solution

by:Manju
Manju earned 250 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to shrink a transaction log file down to a reasonable size.

685 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