Lee posted on May 2, 2009 10:36
Experiences with SSIS calling (yeech) Pervasive as a data source

 

I needed to create a web service to pass data from Pervasive to SAP, and completely bypass SQL Server.  Since I didn’t have the code handy and was too lazy to look on MSDN, I looked around on Google! … and found nothing to write home about. So, here’s my contribution in case you need to write one. Hope it helps someone looking to do same.

When building a web service to call an SSIS package (without touching a SQL Server and in my case calling Pervasive), I had to make a few adjustments that I probably wouldn’t have if we were only talking SQL Server. First, the ProtectionLevel had to be set with encrypt sensitive with password. I found that if I didn’t use this I would have the password default to blank as mentioned in help. Adding password to SSIS package configurations in a table didn’t work either – the password ‘*****’ really was ‘*****’.  So, inside of the web service, you have to use something what I have below. I first thought at first that package.password would work, but you must set the application password.

 
Application app = new Application();
app.PackagePassword = "sql"; 


You can also use the configuration in the project properties configuration tab to lock in the password:

 

image

 

This allows you to use the following to access the password:
 

package.PackagePassword = Properties.Settings.Default.pwd;


 
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Microsoft.SqlServer.Dts.Runtime;


namespace SAPPOC
{
    /// <summary>
    /// Summary description for WebServiceExample
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebServiceExample : System.Web.Services.WebService
    {

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public string POCDates(string StartDt, string EndDt, String packageName)
        {
            string pkg = @"\\yourservernamegoeshere" + packageName.ToString();


            Application app = new Application();
            Package package = app.LoadPackage(pkg, null);
            package.PackagePassword = Properties.Settings.Default.pwd;
            Variables vars = package.Variables;

            vars["StartDt"].Value = StartDt;
            vars["EndDt"].Value = EndDt;

            DTSExecResult result = package.Execute();



            if (result == DTSExecResult.Failure)
                return result.ToString();



            return "SSIS package executed successfully. You sent for start/end: " + StartDt.ToString() + " / " + EndDt.ToString();
        }
    }
}

 
 

Lee

 

-----------------------------

 

Thought for the day: “Compost Happens”


 

 

 

 


Posted in: .Net , SSIS  Tags:
blog comments powered by Disqus

by Lee Everest, M.S.

Poll

Do you use Azure or cloud in your organization?



Show Results

Ads

Search


Month List

Calendar

«  February 2012  »
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011
View posts in large calendar

Tags

Disclaimer
The opinions, code, examples, et.al. expressed herein are my own personal opinions and do not represent my employer's view in any way, shape form, or fashion.  All code for demonstration purposes - no guarantees, either written or implied, are made.

© Copyright 2012 Lee Everest's SQL Server, etc. weblog