May 14, 2008 at 2:58 am
Do you use a proxy? You might have to add one to your code?
The following has worked for me...
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim WebConnection As New WebClient()
Dim proxyConnection As New WebProxy("http://proxy.server.com")
Dim creds As New NetworkCredential("UserName", "Password")
Try
With WebConnection
.Proxy = proxyConnection
.BaseAddress = "https://www.myDomain.com/"
.Credentials = creds
End With
Catch ex As Exception
Dts.Events.FireError(0, "Problem connecting to website: ", ex.Message, "", 0)
End Try
Try
With WebConnection
.DownloadFile("https://www.myDomain.com/folder/", "myFileName.zip")
End With
Catch ex As Exception
Dts.Events.FireError(0, "Problem downloading file: ", ex.Message, "", 0)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
Kindest Regards,
Frank Bazan
May 15, 2008 at 3:41 pm
Hi Frank,
How would your code look without the use of a proxy server?
Thanks,
Dave
May 15, 2008 at 4:14 pm
Hi David,
I'd try just removing the proxy declaration and method...
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim WebConnection As New WebClient()
Dim creds As New NetworkCredential("UserName", "Password")
Try
With WebConnection
.BaseAddress = "https://www.myDomain.com/"
.Credentials = creds
End With
Catch ex As Exception
Dts.Events.FireError(0, "Problem connecting to website: ", ex.Message, "", 0)
End Try
Try
With WebConnection
.DownloadFile("https://www.myDomain.com/folder/", "myFileName.zip")
End With
Catch ex As Exception
Dts.Events.FireError(0, "Problem downloading file: ", ex.Message, "", 0)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
Cheers
Kindest Regards,
Frank Bazan
May 16, 2008 at 7:06 am
Worked like a charm. Thanks, Frank!
May 16, 2008 at 10:09 am
Thanks for your reply. But my URL is different from yours like a path.
http://abc.com/DataUniverse.aspx?SecurityTypeId=ST00000001
I have created a C# program to download the file.
thanks ervery one!
November 10, 2008 at 4:06 pm
Hi I'm doing the same thing, download file from https. the webconnection part works but the downloadfile part doesn't.
With WebConnection
.DownloadFile("http://www.site.com", "file.zip")
is file.zip the file on http or the filename to save as on my machine? and where do i specify where to download to? create a variable?
also i need to compare all the files on https with the files on my local archive folder and then only download those files which are not in my local archive folder. how do i add that piece in the script task?
Thanks!
Viewing 6 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply