I'm trying to execute an SSIS package from an ASP.NET web page. Using some code from http://msdn2.microsoft.com/en-us/library/ms403355.aspx I have managed to get this working when executing a package that contains a stored procedure, however it does not work when there is an Analysis Services cube to build.
Here is my code for the webservice
Public
Class SCCBuildDW Inherits System.Web.Services.WebService ' LaunchPackage Method Parameters: ' 1. sourceType: file, sql, dts ' 2. sourceLocation: file system folder, (none), logical folder ' 3. packageName: for file system, ".dtsx" extension is appended_
Public Function LaunchPackage( _ ByVal sourceType As String, _ ByVal sourceLocation As String, _ ByVal packageName As String) As Integer 'DTSExecResult Dim packagePath As String Dim myPackage As Package Dim integrationServices As New Application ' Combine path and file name.packagePath = Path.Combine(sourceLocation, packageName)
Select Case sourceType Case "file" ' Package is stored as a file. ' Add extension if not present. If String.IsNullOrEmpty(Path.GetExtension(packagePath)) ThenpackagePath =
String.Concat(packagePath, ".dtsx") End If If File.Exists(packagePath) ThenmyPackage = integrationServices.LoadPackage(packagePath,
Nothing) Else Throw New ApplicationException( _ "Invalid file location: " & packagePath) End If Case "sql" ' Package is stored in MSDB. ' Combine logical path and package name. If integrationServices.ExistsOnSqlServer(packagePath, ".", String.Empty, String.Empty) ThenmyPackage = integrationServices.LoadFromSqlServer( _
packageName,
"(local)", String.Empty, String.Empty, Nothing) Else Throw New ApplicationException( _ "Invalid package name or location: " & packagePath) End If Case "dts" ' Package is managed by SSIS Package Store. ' Default logical paths are File System and MSDB. If integrationServices.ExistsOnDtsServer(packagePath, ".") ThenmyPackage = integrationServices.LoadFromDtsServer(packagePath,
"localhost", Nothing) Else Throw New ApplicationException( _ "Invalid package name or location: " & packagePath) End If Case Else Throw New ApplicationException( _ "Invalid sourceType argument: valid values are 'file', 'sql', and 'dts'.") End Select Return myPackage.Execute() End FunctionEnd
Class
This is the code from my page
Protected
Sub btnBuildDW_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuildDW.ClickExecutePackage()
End Sub Protected Sub ExecutePackage() Dim launchPackageService As New SCCBuildDW.SCCBuildDW Dim packageResult As Integer TrypackageResult = launchPackageService.LaunchPackage(
"file", "c:\ssis", "PackageTest") Catch ex As Exception ' The type of exception returned by a Web service is: ' System.Web.Services.Protocols.SoapExceptionlblResult.Text =
"The following exception occurred: " & ex.Message End TrylblResult.Text =
CType(packageResult, PackageExecutionResult).ToString ' Console.ReadKey() End Sub Private Enum PackageExecutionResultPackageSucceeded
PackageFailed
PackageCompleted
PackageWasCancelled
End Enum
I'm using windows authentication and impersonating an identity. The identity has access to the analysis services role but the package still fails to run.
Can anyone offer any help or advice on this
Thanks