bonjour,
je suis en train de créer une application web services avec un coté serveur et un coté client.
le client doit envoyé des requêtes au serveur pour que celui-ci les enregistre dans une BD.
j'ai défini des fonctions que le client a le droit de se servir :
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 function TestEnvoiRequete (const Process_id, login, pwd, pf_emission, pf_destination, nom_fichier, rq_type: string; need_editing : integer) : String;stdcall;
il s'agit donc de 2 fonctions similaires, avec un objet TRequestElement en plus dans la seconde.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 function TestEnvoiRequete3 (const Process_id, login, pwd, pf_emission, pf_destination, nom_fichier, rq_type: string; need_editing : integer; const element : TRequestElement) : String;stdcall;
l'objet TRequestElement est definit dans une unité a part comme ceci:
pour créer mon client j'ai utilisé l'importateur wsdl de delphi qui m'a resorti :
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 type TRequestElement = class(TObject) private FRang : integer; FTypeContenu : WideString; FIdChaine : WideString; FFormat : WideString; FVersion : WideString; FAffaireProgramme : WideString; FDateDiffusion : WideString; protected public constructor Create; destructor Destroy; override; published property AffaireProgramme : WideString read FAffaireProgramme write FAffaireProgramme; property Version : WideString read FVersion write FVersion; property Format : WideString read FFormat write FFormat; property TypeContenu : WideString read FTypeContenu write FTypeContenu; property IdChaine : WideString read FIdChaine write FIdChaine; property DateDiffusion : WideString read FDateDiffusion write FDateDiffusion; property Rang : integer read FRang write FRang; end;
maintenant dans la form de mon applicatiojn cliente, j'ai un bouton sur lequel j'effectue l'appel de la fonction TestEnvoiRequete3
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 unit IMyWs1; interface uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns, Dialogs; type // ************************************************************************ // // Les types suivants mentionnés dans le document WSDL ne sont pas représentés // dans ce fichier. Ce sont soit des alias[@] de types représentés ou alors ils sont // référencés mais jamais[!] déclarés dans ce document. Les types de la dernière catégorie // sont en principe mappés à des types Borland ou XML prédéfinis/connus. Toutefois, ils peuvent aussi // signaler des documents WSDL incorrects n'ayant pas réussi à déclarer ou importer un type de schéma. // ************************************************************************ // // !:string - "http://www.w3.org/2001/XMLSchema" // !:dateTime - "http://www.w3.org/2001/XMLSchema" // !:int - "http://www.w3.org/2001/XMLSchema" TRequestElement = class; { "urn:URequestObject" } // ************************************************************************ // // Espace de nommage : urn:URequestObject // ************************************************************************ // TRequestElement = class(TRemotable) private FAffaireProgramme : WideString; FVersion : WideString; FFormat : WideString; FTypeContenu : WideString; FIdChaine : WideString; FDateDiffusion : WideString; FRang : Integer; public destructor Destroy; override; published property AffaireProgramme: WideString read FAffaireProgramme write FAffaireProgramme stored False; property Version: WideString read FVersion write FVersion stored False; property Format: WideString read FFormat write FFormat stored False; property TypeContenu: WideString read FTypeContenu write FTypeContenu stored False; property IdChaine: WideString read FIdChaine write FIdChaine stored False; property DateDiffusion: WideString read FDateDiffusion write FDateDiffusion stored False; property Rang: Integer read FRang write FRang stored False; end; // ************************************************************************ // // Espace de nommage : urn:UMyWsIntf-IMyWs // soapAction : urn:UMyWsIntf-IMyWs#%operationName% // transport : <a href="http://schemas.xmlsoap.org/soap/http" target="_blank">http://schemas.xmlsoap.org/soap/http</a> // style : rpc // liaison : IMyWsbinding // service : IMyWsservice // port : IMyWsPort // URL : <a href="http://192.168.2.133/cgi-bin/wssoap.exe/soap/IMyWs" target="_blank">http://192.168.2.133/cgi-bin/wssoap.exe/soap/IMyWs</a> // ************************************************************************ // IMyWs = interface(IInvokable) ['{A71CD1DD-5536-F2FD-2679-7146738EBED6}'] function TestEnvoiRequete(const Process_id: WideString; const login: WideString; const pwd: WideString; const pf_emission: WideString; const pf_destination: WideString; const nom_fichier: WideString; const rq_type: WideString; const need_editing: Integer): WideString; stdcall; function TestEnvoiRequete3(const Process_id: WideString; const login: WideString; const pwd: WideString; const pf_emission: WideString; const pf_destination: WideString; const nom_fichier: WideString; const rq_type: WideString; const need_editing: Integer; const element: TRequestElement): WideString; stdcall; end; function GetIMyWs(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IMyWs; implementation function GetIMyWs(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IMyWs; const defWSDL = 'http://192.168.2.133/cgi-bin/wssoap.exe/wsdl/IMyWs'; defURL = 'http://192.168.2.133/cgi-bin/wssoap.exe/soap/IMyWs'; defSvc = 'IMyWsservice'; defPrt = 'IMyWsPort'; var RIO: THTTPRIO; begin Result := nil; if (Addr = '') then begin if UseWSDL then Addr := defWSDL else Addr := defURL; end; if HTTPRIO = nil then RIO := THTTPRIO.Create(nil) else RIO := HTTPRIO; try Result := (RIO as IMyWs); if UseWSDL then begin RIO.WSDLLocation := Addr; RIO.Service := defSvc; RIO.Port := defPrt; end else RIO.URL := Addr; finally if (Result = nil) and (HTTPRIO = nil) then RIO.Free; end; end; destructor TRequestElement.Destroy; begin inherited Destroy; end; initialization InvRegistry.RegisterInterface(TypeInfo(IMyWs), 'urn:UMyWsIntf-IMyWs', 'utf-8'); InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IMyWs), 'urn:UMyWsIntf-IMyWs#%operationName%'); RemClassRegistry.RegisterXSClass(TRequestElement, 'urn:URequestObject', 'TRequestElement'); end.
comme ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 procedure TForm1.BtInsertClick(Sender: TObject); var tempElement : TRequestElement; tp : string; begin tempElement := GBL_ElementList[0]; tp := GetIMyWs.TestEnvoiRequete3(EdProcessId.Text, EdUser.Text, EdPwd.Text, EdPF_Emission.Text, EdPF_Destination.Text, EdNom_Fichier.Text, EdType.Text, strToInt(EdNeed_Editing.Text), tempElement); Memo.Lines.Add(tp); end;
mon pb intervient a ce niveau là.
tous les champs sont remplis, et l'objet "tempElement" n'est pas vide, mais à la reception de la fonction coté serveur, les attributs strings
ont les bonnes valeurs, alors que l'objet de type TRequestElment lui est NIL et je sais pas pourquoi ni comment faire pour rectifier ça.
je solicite donc votre aide.
merci d'avance
Partager