Bonjour
J'ai écrit la partie serveur d'un web service, mais son exécution renvoie l'erreur "Violation d'accès à l'adresse 022C107E dans le module 'Project1.dll"
L'erreur se produit sur la ligne suivante, lors de l'affectation de la valeur de la requète à Mon_Portefeuille[Nb_Client].Num_client
Je pense que problème vient du fait que le tableau Mon_Portefeuille n'est pas créé, mais comment le créer ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Mon_Portefeuille[Nb_Client].Num_client := FieldByName('num_client').Value;
Merci d'avance pour vos réponses
Voici ci-dessous la descrition de l'interface :
-------------------------------------------
et l'implémentation :
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 interface uses InvokeRegistry, Types, XSBuiltIns; type Enr = Class; Enr = Class(TRemotable) private FNum_client : integer; FDesignation : widestring; FQualite : Widestring; published property Num_client : integer read FNum_client write FNum_client; property Designation : widestring read FDesignation write Fdesignation; property Qualite : widestring read FQualite write FQualite; end; Portefeuille = array of Enr; { Les interfaces invocables doivent dériver de IInvokable } ITestIO = interface(IInvokable) ['{7BA0A86E-0CCC-42F1-9828-F8EDE440CBE1}'] function Lit_Portefeuille(Code_agent : integer) : Portefeuille ; stdcall; { Les méthodes de l'interface invocable ne doivent pas utiliser la convention } { d'appel par défaut ; stdcall est conseillée } end; implementation initialization { Les interfaces invocables doivent être recensées } InvRegistry.RegisterInterface(TypeInfo(ITestIO)); end.
-------------------
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 { Fichier d'implémentation invocable pour TTestIO qui implémente ITestIO } unit TestIOImpl; interface uses InvokeRegistry, Types, XSBuiltIns, TestIOIntf, cer_fichiers, sysutils; type { TTestIO } TTestIO = class(TInvokableClass, ITestIO) public function Lit_Portefeuille(Code_agent : integer) : Portefeuille ; stdcall; end; implementation uses Unit1, Unit2; function TTestIO.Lit_Portefeuille(Code_agent : integer) : Portefeuille; var MyDataModule : TDataModule; Mon_Portefeuille : Portefeuille; Nb_Client : integer; begin MyDataModule := TDataModule.create(nil); try With MyDataModule.QPortefeuille do begin Close; ParamByName('code_agent').Value := Code_agent; Open; Nb_Client := 0; While not Eof do begin inc(Nb_Client); Mon_Portefeuille[Nb_Client].Num_client := FieldByName('num_client').Value; Mon_Portefeuille[Nb_Client].Designation := FieldByName('designation').Value; Mon_Portefeuille[Nb_Client].Qualite := FieldByName('qualite').Value; Next; end; Close; end; finally FreeAndNil (MyDataModule); end; result := Mon_Portefeuille; end; initialization { Les classes invocables doivent être recensées } InvRegistry.RegisterInvokableClass(TTestIO); end.
Partager