Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

http connection manager and script task to download a xml file from a secured website

$
0
0

Hi All,

I want to download xml file from a secured website. I have created a package.

1. HTTP connection was added - Credentials were given. Client certificate was chosen. Connection was tested and it works fine.

2. Following c# code was included in the main method in the script task.

#region Namespaces
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;
#endregion

namespace ST_51cd75afde23429aad7bf937031b5de8
{
    	[Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
	public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
	{
       		public void Main()
		{

            Microsoft.SqlServer.Dts.Runtime.HttpClientConnection httpConn;
            Object obj;

            try
            {
                obj = Dts.Connections["HTTP Connection Manager"].AcquireConnection(null);
                httpConn = new HttpClientConnection(obj);
                httpConn.DownloadFile(@"C:\Users\" + Guid.NewGuid() + ".xml", true);
            }
            catch (Exception e)
            {
                Dts.Events.FireError(1, e.TargetSite.ToString(), e.Message, "", 0);
            }
			// TODO: Add your code here

			Dts.TaskResult = (int)ScriptResults.Success;
		}

       
        enum ScriptResults
        {
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        };
        

	}
}

Package runs successfully. However When I open the xml file, I don't see any data there. I see the following error message.

"invalid user id/password pair"

<?xml version="1.0"?>
-<my-query-result-set> <start-time>2013/11/13 13:18:29</start-time> <usns-lastmod-dtg>201311131318</usns-lastmod-dtg> <query-type>all my</query-type> <query-parameter/> <error>invalid user id/password pair</error> <rec-count>0</rec-count> <end-time>2013/11/13 13:18:29</end-time> </my-query-result-set>
The same file is successfully downloaded with data using a .NET project.

Can anyone tell me why I don't see the data here.

Thanks


shamen


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>