Bonjour messieurs,
Je construit actuellement un petit web service de gestion de ma base de donnée.
Seulement une chose me pose problème je ne peux renvoyer des array d'objet mais pas de list.
Mon objet.
Ma méthode dans le wsdl :
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 public class Pronostique implements Serializable{ private int id; private String prenom; private String nom; private int opt1; private int opt2; private int opt3; private String societe; private int participation; public Pronostique() { } public Pronostique(int id, String prenom, String nom, int opt1, int opt2, int opt3, String societe, int participation) { this.id = id; this.prenom = prenom; this.nom = nom; this.opt1 = opt1; this.opt2 = opt2; this.opt3 = opt3; this.societe = societe; this.participation = participation; } public Pronostique(String prenom, String nom, int opt1, int opt2, int opt3, String societe, int participation) { this.prenom = prenom; this.nom = nom; this.opt1 = opt1; this.opt2 = opt2; this.opt3 = opt3; this.societe = societe; this.participation = participation; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getPrenom() { return prenom; } public void setPrenom(String prenom) { this.prenom = prenom; } public String getNom() { return nom; } public void setNom(String nom) { this.nom = nom; } public int getOpt1() { return opt1; } public void setOpt1(int opt1) { this.opt1 = opt1; } public int getOpt2() { return opt2; } public void setOpt2(int opt2) { this.opt2 = opt2; } public int getOpt3() { return opt3; } public void setOpt3(int opt3) { this.opt3 = opt3; } public String getSociete() { return societe; } public void setSociete(String societe) { this.societe = societe; } public int getParticipation() { return participation; } public void setParticipation(int participation) { this.participation = participation; } }
La pas de problème on me renvoie bien les différents utilisateur de ma table pronostique.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 @WebMethod(operationName = "getPronostique", action = "getPronostique") public Pronostique[] getPronostique() { PronostiqueDao pronostiqueDao = (PronostiqueDao) ac.getBean("pronostiqueDao"); ArrayList<Pronostique> pronostiques = pronostiqueDao.getPronostiqueById(); return pronostiques.toArray(new Pronostique[pronostiques.size()]); }
Mais par contre avec ca :
La réponse du web service avec soapui
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 @WebMethod(operationName = "testlist", action = "testlist") public ArraylistPronostique testlist() { PronostiqueDao pronostiqueDao = (PronostiqueDao) ac.getBean("pronostiqueDao"); ArrayList<Pronostique> pronostiques = pronostiqueDao.getPronostiqueById(); return pronostiques.toArray(new Pronostique[pronostiques.size()]); }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> <S:Body> <ns2:testlistResponse xmlns:ns2="http://ws.societe.com/"> <return/> </ns2:testlistResponse> </S:Body> </S:Envelope>
Ma question est simple on ne peut pas renvoyer de list avec un web service, on est obliger de renvoyé un tableau ? donc pas de renvoie de MAP possible ?
J'ai regarder les type XML Schema Part 2: Datatypes Second Edition
Pour voir quel types pouvaient être renvoyer avec les web service.
ici
Et la a ma grande surprise :
[Definition:] Atomic datatypes are those having values which are regarded by this specification as being indivisible.
[Definition:] List datatypes are those having values each of which consists of a finite-length (possibly empty) sequence of values of an ·atomic· datatype.
[Definition:] Union datatypes are those whose ·value space·s and ·lexical space·s are the union of the ·value space·s and ·lexical space·s of one or more other datatypes.
Donc si quelqu'un peut m'éclairer sur sa je lui en serrais reconnaissant car je n’avoue plus comprendre.
Partager