Bonjour,

J'ai créé un service web en C# qui fonctionne parfaitement sur le serveur de développement. Lorsque je le met sur le serveur de prod il ne fonctionne plus.

J'ai regardé les paths et les droits, je ne crois pas que mon problème provient de là.

Voici le code du WebService:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Diagnostics;
 
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
    public Service () {
 
        //Supprimez les marques de commentaire dans la ligne suivante si vous utilisez des composants conçus 
        //InitializeComponent(); 
    }
 
    [WebMethod]
    public void convert2pdf(string sourcefile, string directory) {
        // Instance de la classe Process
        Process proc = new Process();
        // Nom de l'executable à lancer
        proc.StartInfo.FileName = "cscript";
        // Arguments à passer à l'exécutable à lancer
        proc.StartInfo.Arguments = "C:\\Webhome/convert2pdf/convert2pdf.js " + sourcefile + " " + directory;
        // Démarrage du processus
        proc.Start();
        // On libère les ressources dont on n'a plus besoin.
        proc.Close(); // Attention Close ne met pas fin au processus.
    }
 
}
Et le code du JScript :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Convert2PDF.js script
// Part of PDFCreator
// License: GPL
// Homepage: http://www.pdfforge.org/products/pdfcreator
// Windows Scripting Host version: 5.1
// Homepage: http://www.sf.net/projects/pdfcreator
// Version: 1.0.0.0
// Date: March, 15. 2007
// Author: Frank Heindörfer
// Comments: This script convert a printable file in a pdf-file using 
//           the com interface of PDFCreator.
 
try {
var fs = new ActiveXObject("Scripting.FileSystemObject");
var a = fs.CreateTextFile("c:\\test02.txt", true, true);
a.WriteLine("Debut");
 
var maxTime = 30   // in seconds
var sleepTime = 250 // in milliseconds
 
var objArgs, ifname, dirname, fso, PDFCreator, DefaultPrinter, ReadyState,
 i, c, Scriptname;
 
a.WriteLine("Var OK");
 
fso = new ActiveXObject("Scripting.FileSystemObject");
 
Scriptname = fso.GetFileName(WScript.ScriptFullname);
 
a.WriteLine("fso OK");
 
if (WScript.Version < 5.1)
{
 WScript.Echo("You need the \"Windows Scripting Host version 5.1\" or greater!");
 WScript.Quit();
}
 
a.WriteLine("WScript.Version OK");
 
if (WScript.arguments.length == 0)
{
 WScript.Echo("Syntax: \t" + Scriptname + " <Filename> <Dirname>");
 WScript.Quit();
}
 
a.WriteLine("Arguments OK");
 
PDFCreator = WScript.CreateObject("PDFCreator.clsPDFCreator", "PDFCreator_");
a.WriteLine("PDFCreator create OK"); 
PDFCreator.cStart("/NoProcessingAtStartup");
 
a.WriteLine("PDFCreator start OK");
 
PDFCreator.cOption("UseAutosave") = 1;
PDFCreator.cOption("UseAutosaveDirectory") = 1;
PDFCreator.cOption("AutosaveFormat") = 0;                             // 0 = PDF
//DefaultPrinter = PDFCreator.cDefaultprinter;
PDFCreator.cDefaultprinter = "PDFCreator";
PDFCreator.cClearcache();
 
a.WriteLine("Options OK");
 
ifname = WScript.arguments.item(0)
dirname = WScript.arguments.item(1)
 
 
if (!fso.FileExists(ifname)) {
   WScript.Echo("Can't find the file: " + ifname);
}
else {
	a.WriteLine("FileExists OK");
  if (!PDFCreator.cIsPrintable(ifname)) {
    WScript.Echos("Converting: " + ifname + "\r\n\r\nAn error is occured: File is not printable!");
    PDFCreator.cClose();
    a.Close();
    WScript.Quit();
  }
  a.WriteLine("IsPrintable OK");
  ReadyState = 0
 
  PDFCreator.cOption("AutosaveDirectory") = dirname;
  PDFCreator.cOption("AutosaveFilename") = fso.GetBaseName(ifname);
  a.WriteLine("avt impression");
  PDFCreator.cPrintfile(ifname);
  PDFCreator.cPrinterStop = false;
  a.WriteLine("apres impression");
 
  c = 0
  while ((ReadyState == 0) && (c < (maxTime * 1000 / sleepTime)))
  {
    c = c + 1;
    WScript.Sleep(sleepTime);
    a.WriteLine(c);
  }
  if (ReadyState == 0)
  {
    WScript.Echo("Converting: " + ifname + "\r\n\r\nAn error is occured: Time is up!");
  }
 
}
 
//PDFCreator.cDefaultprinter = DefaultPrinter
PDFCreator.cClearcache();
WScript.Sleep(200);
PDFCreator.cClose();
 
a.WriteLine("Fin");
 
a.Close();
 
}catch(err){a.WriteLine("Error:");a.WriteLine(err.description);}
 
//--- PDFCreator events ---
 
function PDFCreator_eReady()
{
var fs2 = new ActiveXObject("Scripting.FileSystemObject");
var a2 = fs.CreateTextFile("c:\\test2.txt", true, true);
 ReadyState = 1;
 a2.WriteLine("ReadyState OK");
 a2.Close();
}
 
function PDFCreator_eError()
{
var fs3 = new ActiveXObject("Scripting.FileSystemObject");
var a3 = fs.CreateTextFile("c:\\test3.txt", true, true);
a3.WriteLine("PDFCreator_eError");
a3.Close();
 WScript.Echo("An error is occured!\r\n\r\n"  +
  "Error [" + PDFCreator.cErrorDetail("Number") + "]: " + PDFCreator.cErrorDetail("Description"));
 WScript.Quit();
}
Enfin l'exception lancée en prod :
Impossible de créer l'objet appelé "PDFCreator.clsPDFCreator".
Et voici l'erreur avec un code entièrement C# équivalent :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="convert2pdf">
La récupération de la fabrique de classe COM pour le composant avec le
CLSID {FBAAB693-CD00-42DE-ADB1-C5E5CA03700D} a échoué en raison de
l'erreur suivante : 80070005.
</string>
Voilà !
Je serais très enchanté si quelqu'un avait une idée de l'origine de mon problème !

Merci d'avance,

NiKo.