Bonjour,
Je développe une dll (en visual c# sous visual studio 2005) qui fait appel à des WebService.
Voici la Wsdl qui me pose problème :
Voici le code que j’ai écrit pour tester l’appel:
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 <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://webservices.dossier.digitech.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservices.dossier.digitech.com" xmlns:intf="http://webservices.dossier.digitech.com" xmlns:tns1="http://type.webservices.dossier.digitech.com" xmlns:tns2="http://exception.webservices.dossier.digitech.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://webservices.dossier.digitech.com" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://exception.webservices.dossier.digitech.com"/> <import namespace="http://type.webservices.dossier.digitech.com"/> <element name="getTerms"> <complexType> <sequence> <element name="connectionData" type="tns1:WSConnectionType"/> <element name="fieldCode" type="xsd:string"/> </sequence> </complexType> </element> <element name="getTermsResponse"> <complexType> <sequence> <element maxOccurs="unbounded" name="getTermsReturn" type="tns1:WSTerm"/> </sequence> </complexType> </element> <element name="fault" type="tns2:WSAuthorityListException"/> </schema> <schema elementFormDefault="qualified" targetNamespace="http://type.webservices.dossier.digitech.com" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://exception.webservices.dossier.digitech.com"/> <complexType name="WSConnectionType"> <sequence> <element name="authentificationId" nillable="true" type="xsd:string"/> <element name="login" nillable="true" type="xsd:string"/> <element name="password" nillable="true" type="xsd:string"/> </sequence> </complexType> <complexType name="WSTerm"> <sequence> <element name="code" nillable="true" type="xsd:string"/> <element name="id" nillable="true" type="xsd:int"/> </sequence> </complexType> </schema> <schema elementFormDefault="qualified" targetNamespace="http://exception.webservices.dossier.digitech.com" xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://type.webservices.dossier.digitech.com"/> <complexType name="WSAuthorityListException"> <sequence/> </complexType> </schema> </wsdl:types> <wsdl:message name="getTermsResponse"> <wsdl:part element="impl:getTermsResponse" name="parameters"/> </wsdl:message> <wsdl:message name="WSAuthorityListException"> <wsdl:part element="impl:fault" name="fault"/> </wsdl:message> <wsdl:message name="getTermsRequest"> <wsdl:part element="impl:getTerms" name="parameters"/> </wsdl:message> <wsdl:portType name="WSAuthorityList"> <wsdl:operation name="getTerms"> <wsdl:input message="impl:getTermsRequest" name="getTermsRequest"/> <wsdl:output message="impl:getTermsResponse" name="getTermsResponse"/> <wsdl:fault message="impl:WSAuthorityListException" name="WSAuthorityListException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="WSAuthorityListSoapBinding" type="impl:WSAuthorityList"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getTerms"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getTermsRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="getTermsResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="WSAuthorityListException"> <wsdlsoap:fault name="WSAuthorityListException" use="literal"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:service name="WSAuthorityListService"> <wsdl:port binding="impl:WSAuthorityListSoapBinding" name="WSAuthorityList"> <wsdlsoap:address location="http://localhost:9090/AirsDossier/services/WSAuthorityList"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Je n'ai pas de plantage de mon appli mais le resultat est que j’ai bien un “Result” de la bonne dimension (4 éléments dans ce cas)
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 WSAuthorityListService m_AuthorityList = new WSAuthorityListService(); m_AuthorityList.Url="http://localhost:9090/AirsDossier/services/WSAuthorityList"; WSConnectionType InfoCnx = new WindowsApplication1.WSAuthorityList.WSConnectionType(); InfoCnx.login = "adm_airs3"; InfoCnx.password = "adm_airs3"; try { WSTerm[] Result = m_AuthorityList.getTerms(InfoCnx, "STATUT"); } catch (System.Exception er) { MessageBox.Show(er.Message); }
mais pour chacun d’eux, les 2 propriétés (code et id) on la valeur null.
J’ai testé ce WebService sous soapUI, et il fonctionne.
le resultat sous soapUI:
Au cours de mes recherches pour résoudre ce problème, j’ai comparé la wsdl avec celle d’un autre WebService qui renvoie également un tableau de « structure » et qui ne me pose pas de problème.
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 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <getTermsResponse xmlns="http://webservices.dossier.digitech.com"> <getTermsReturn> <code>001</code> <id>116</id> </getTermsReturn> <getTermsReturn> <code>100</code> <id>53</id> </getTermsReturn> <getTermsReturn> <code>200</code> <id>54</id> </getTermsReturn> <getTermsReturn> <code>300</code> <id>55</id> </getTermsReturn> </getTermsResponse> </soapenv:Body> </soapenv:Envelope>
La différence que j’ai noté est que dans la déclaration des types (balise <wsdl:types>) , les élément "getTerms" et « WSTerm » se trouve dans des « schema » différent. (désolé si je n’emploie pas les bon termes, je débute en WebService) .
J’ai donc modifié à la « main » la wsdl afin d’avoir tous dans le même « schema ».
voici la wsdl modifiée :
Et là, cela fonctionne.
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 <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://webservices.dossier.digitech.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservices.dossier.digitech.com" xmlns:intf="http://webservices.dossier.digitech.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)--> <wsdl:types> <schema elementFormDefault="qualified" targetNamespace="http://webservices.dossier.digitech.com" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="getTerms"> <complexType> <sequence> <element name="connectionData" type="impl:WSConnectionType"/> <element name="fieldCode" type="xsd:string"/> </sequence> </complexType> </element> <element name="getTermsResponse"> <complexType> <sequence> <element maxOccurs="unbounded" name="getTermsReturn" type="impl:WSTerm"/> </sequence> </complexType> </element> <complexType name="WSConnectionType"> <sequence> <element name="authentificationId" nillable="true" type="xsd:string" /> <element name="login" nillable="true" type="xsd:string" /> <element name="password" nillable="true" type="xsd:string" /> </sequence> </complexType> <complexType name="WSTerm"> <sequence> <element name="code" nillable="true" type="xsd:string" /> <element name="id" nillable="true" type="xsd:int" /> </sequence> </complexType> <complexType name="WSAuthorityListException"> <sequence /> </complexType> <element name="fault" type="impl:WSAuthorityListException"/> </schema> </wsdl:types> <wsdl:message name="getTermsResponse"> <wsdl:part element="impl:getTermsResponse" name="parameters"/> </wsdl:message> <wsdl:message name="WSAuthorityListException"> <wsdl:part element="impl:fault" name="fault"/> </wsdl:message> <wsdl:message name="getTermsRequest"> <wsdl:part element="impl:getTerms" name="parameters"/> </wsdl:message> <wsdl:portType name="WSAuthorityList"> <wsdl:operation name="getTerms"> <wsdl:input message="impl:getTermsRequest" name="getTermsRequest"/> <wsdl:output message="impl:getTermsResponse" name="getTermsResponse"/> <wsdl:fault message="impl:WSAuthorityListException" name="WSAuthorityListException"/> </wsdl:operation> </wsdl:portType> <wsdl:binding name="WSAuthorityListSoapBinding" type="impl:WSAuthorityList"> <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="getTerms"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="getTermsRequest"> <wsdlsoap:body use="literal"/> </wsdl:input> <wsdl:output name="getTermsResponse"> <wsdlsoap:body use="literal"/> </wsdl:output> <wsdl:fault name="WSAuthorityListException"> <wsdlsoap:fault name="WSAuthorityListException" use="literal"/> </wsdl:fault> </wsdl:operation> </wsdl:binding> <wsdl:service name="WSAuthorityListService"> <wsdl:port binding="impl:WSAuthorityListSoapBinding" name="WSAuthorityList"> <wsdlsoap:address location="http://localhost:8080/AirsDossier/services/WSAuthorityList"/> </wsdl:port> </wsdl:service> </wsdl:definitions>
Par contre, allez modifier à la main la wsdl ne me semble pas être une méthode acceptable.
L’autre solution que j’ai également testée, est d’aller modifier le fichier « Reference.cs » qui est générer lors de l’ajout d’un « Web Reference » en remplaçant ce code
par celui ci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.5420")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://type.webservices.dossier.digitech.com")] public partial class WSTerm {
Mais il y a un risque que le fichier soit régénérer.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.5420")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://webservices.dossier.digitech.com")] public partial class WSTerm {
Je souhaiterais donc une solution plus propre.
Merci d’avance
Partager