Bonjour,
Je dois insérer dans un TClientDataSet les data renvoyés par un web service (Serveur Ensemble - intersystem) dans un format XML SOAP (cf. PJ)
Pour toute la partie de gestion du WSDL pas de soucis. Par contre lorsque je souhaite exploiter le XML, il ne me renvoie les sous éléments.
Pour ce faire, j'ai utilisé le XML Data binding qui m'a généré (entre autre) les interfaces suivantes :
Pour l'exploiter, je me suis maquetté la méthode suivante :
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 { IXMLDefaultDataSetType } IXMLDefaultDataSetType = interface(IXMLNodeCollection) ['{AD70BD6E-0331-45DF-A93D-6945F6F5D9EE}'] { Property Accessors } function Get_ContainerHistory(Index: Integer): IXMLContainerHistoryType; { Methods & Properties } function Add: IXMLContainerHistoryType; function Insert(const Index: Integer): IXMLContainerHistoryType; property ContainerHistory[Index: Integer]: IXMLContainerHistoryType read Get_ContainerHistory; default; end; { IXMLContainerHistoryType } IXMLContainerHistoryType = interface(IXMLNode) ['{E76A932C-65E1-42C9-A444-072776E418D4}'] { Property Accessors } function Get_MoveDate: UnicodeString; function Get_MT: UnicodeString; function Get_NbErrors: Integer; function Get_Container: UnicodeString; function Get_Description: UnicodeString; function Get_MoveLocation: UnicodeString; function Get_ACC: UnicodeString; function Get_AgentAlternateName: UnicodeString; function Get_POL: UnicodeString; function Get_POD: UnicodeString; function Get_Vessel: UnicodeString; function Get_Voyage: UnicodeString; function Get_BLNumber: UnicodeString; function Get_SessionTimeStamp: UnicodeString; function Get_MoveFileName: UnicodeString; function Get_ContainerId: Integer; function Get_DocId: Integer; function Get_MovementId: Integer; procedure Set_MoveDate(Value: UnicodeString); procedure Set_MT(Value: UnicodeString); procedure Set_NbErrors(Value: Integer); procedure Set_Container(Value: UnicodeString); procedure Set_Description(Value: UnicodeString); procedure Set_MoveLocation(Value: UnicodeString); procedure Set_ACC(Value: UnicodeString); procedure Set_AgentAlternateName(Value: UnicodeString); procedure Set_POL(Value: UnicodeString); procedure Set_POD(Value: UnicodeString); procedure Set_Vessel(Value: UnicodeString); procedure Set_Voyage(Value: UnicodeString); procedure Set_BLNumber(Value: UnicodeString); procedure Set_SessionTimeStamp(Value: UnicodeString); procedure Set_MoveFileName(Value: UnicodeString); procedure Set_ContainerId(Value: Integer); procedure Set_DocId(Value: Integer); procedure Set_MovementId(Value: Integer); { Methods & Properties } property MoveDate: UnicodeString read Get_MoveDate write Set_MoveDate; property MT: UnicodeString read Get_MT write Set_MT; property NbErrors: Integer read Get_NbErrors write Set_NbErrors; property Container: UnicodeString read Get_Container write Set_Container; property Description: UnicodeString read Get_Description write Set_Description; property MoveLocation: UnicodeString read Get_MoveLocation write Set_MoveLocation; property ACC: UnicodeString read Get_ACC write Set_ACC; property AgentAlternateName: UnicodeString read Get_AgentAlternateName write Set_AgentAlternateName; property POL: UnicodeString read Get_POL write Set_POL; property POD: UnicodeString read Get_POD write Set_POD; property Vessel: UnicodeString read Get_Vessel write Set_Vessel; property Voyage: UnicodeString read Get_Voyage write Set_Voyage; property BLNumber: UnicodeString read Get_BLNumber write Set_BLNumber; property SessionTimeStamp: UnicodeString read Get_SessionTimeStamp write Set_SessionTimeStamp; property MoveFileName: UnicodeString read Get_MoveFileName write Set_MoveFileName; property ContainerId: Integer read Get_ContainerId write Set_ContainerId; property DocId: Integer read Get_DocId write Set_DocId; property MovementId: Integer read Get_MovementId write Set_MovementId; end;
Le souci est que LstMvt.Count me renvoie toujours 0 alors qu'il y a bien des éléments dans le XML.
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 procedure TForm1.cxButton1Click(Sender: TObject); var Header : IXMLEnvelopeType; LstMvt : IXMLDefaultDataSetType; Mvt : IXMLContainerHistoryType; I: Integer; begin Mo.Lines.Clear; Header := LoadEnvelope('C:\Temp\ContainerHistory - Copy.xml'); if Assigned(Header) then begin LstMvt := Header.Body.GetContainerHistoryResponse.GetContainerHistoryResult.Diffgram.DefaultDataSet; for I := 0 to LstMvt.Count -1 do begin Mvt := LstMvt.ContainerHistory[I]; if Assigned(Mvt) then Mo.Lines.Add(Mvt.MoveDate); end; end; end;
Les variables d'interface sont bien valorisées.
J'ai essayé de récupérer un élément en hard codant LstMvt.ContainerHistory[0] et dans ce cas il me renvoie une erreur "Index out of bounds".
Est-ce quelqu'un aurait une idée ?
Merci d'avance.
Partager