2013-05-21 8 views
0

J'ai un service Web appelant un ssis sans problème sur localhost. Mais quand je le déploie, il ne fonctionne pas et ne donne aucune erreur. Où dois-je changer pour autoriser la demande de la télécommande? Je crois qu'il y a quelque chose qui empêche de demander ... C'est mon code.Exécution de SSIS à distance avec WCF

public class blaService : IblaService 
{ 

    [WebMethod] 
    [WebGet(UriTemplate = "runSSISPackage/{Id}")] 
    public string runSSISPackage(string Id) 
    { 
     try 
     { 
      string pkgLocation = ConfigurationManager.AppSettings["dtsxPath"].ToString(); 

      Package pkg; 
      Application app; 
      DTSExecResult pkgResults; 
      Variables vars; 

      string databaseName, tableName, minId, maxId, sCreatedDateTime, filePathTemplate, folderName; 
      Int64 fileRowAmount, fileCount; 
      using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString.SQL Server (SqlClient)"].ConnectionString.ToString())) 
      { 
       sqlConnection.Open(); 
       SqlCommand sqlCommand = new SqlCommand("select * from dbo.Table where Id=" + Convert.ToInt32(Id), sqlConnection); 
       sqlCommand.CommandTimeout = 0; 
       SqlDataReader reader = sqlCommand.ExecuteReader(); 

       if (reader.Read()) 
       { 

        databaseName = reader["DatabaseName"].ToString(); 
        tableName = reader["TableName"].ToString(); 
        minId = reader["MinimumId"].ToString(); 
        maxId = reader["MaximumId"].ToString(); 
        fileRowAmount = Int64.Parse(reader["FileRowAmount"].ToString()); 
        fileCount = Int64.Parse(reader["FileCount"].ToString()); 
        sCreatedDateTime = Convert.ToDateTime(reader["CreatedDateTime"]).ToString("yyyyMMddHHmmss"); 

        filePathTemplate = ConfigurationManager.AppSettings["outputFilePath"].ToString(); 
        folderName = "bla_" + sCreatedDateTime; 

        if (!Directory.Exists(string.Format(filePathTemplate + "\\{0}", folderName))) 
        { 
         Directory.CreateDirectory(string.Format(filePathTemplate + "\\{0}", folderName)); 
        } 

        app = new Application(); 
        pkg = app.LoadPackage(pkgLocation, null); 
        vars = pkg.Variables; 
        vars["DBName"].Value = "bla_PasswordPool"; 
        vars["FileCount"].Value = fileCount; 
        vars["FileName"].Value = "bla_" + sCreatedDateTime + "_1of1.txt"; 
        vars["FileNamePrefix"].Value = "bla_" + sCreatedDateTime + "_"; 
        vars["FileRowAmount"].Value = fileRowAmount; 
        vars["i"].Value = 0; 
        //vars["OutputFolder"].Value = @"C:\SSIS\blaSifreTakip\"; 
        vars["OutputFolder"].Value = string.Format(filePathTemplate + "\\{0}", folderName); 
        vars["SelectSQLQuery"].Value = "select sifre from " + tableName + " where Id>" + minId + " And Id<=" + maxId + " order by Id"; 
        vars["StartRowIndex"].Value = minId; 
        vars["TableName"].Value = tableName; 


        pkgResults = pkg.Execute(null, vars, null, null, null); 

        if (pkgResults == DTSExecResult.Success) 
        { 
         PasswordPackDataInfoEntity pp = new PasswordPackDataInfoEntity(Convert.ToInt32(Id)); 
         pp.Status = 2; 
         pp.Save(); 

         return "Success"; 
        } 


       } 
       else 
       { 
        return "Empty"; 
       } 

      } 

      return ""; 

     } 
     catch (DtsException e) 
     { 

      return e.Message.ToString(); 
     } 

    } 

Répondre

1

Il s'agit généralement d'un problème d'autorisation entre IIS et SQL Server (moteur SSIS).
Dans IIS, consultez le pool d'applications utilisé par votre application WCF (dossier IIS). Si c'est dans le pool par défaut, créez un nouveau pool et attribuez un compte d'utilitaire (pour rendre les choses plus faciles &). Ce compte doit être autorisé à lire les fichiers de votre dossier de paquetage SSIS (configuré) et il a besoin d'autorisations d'administrateur sur la base de données cible.
Voici un fil de discussion qui explique plusieurs pièces du puzzle. C'est un peu verbeux, mais très approfondi: http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/ff441dc3-b43b-486b-8be1-00126cf53812/

Questions connexes