Précédent   Forum du club des développeurs et IT Pro > Autres langages > XML/XSL et SOAP > APIs
APIs DOM, SAX, JAXP,STAX... leur fonctionnement, leurs implémentations Avant de poster -> FAQ XML
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 22/07/2008, 18h07   #1
localhost
Membre du Club
 
Inscription : mai 2002
Messages : 93
Détails du profil
Informations forums :
Inscription : mai 2002
Messages : 93
Points : 49
Points : 49
Envoyer un message via MSN à localhost Envoyer un message via Yahoo à localhost Envoyer un message via Skype™ à localhost
Par défaut [WSDL] Probléme de passage d'un type matrice à double tableaux

Bonjour à tous,
J'essaie de créer une API Webservice SOAP en utilisant SoapServer, je construis mon WSDL manuellement et je n'ai aucun probléme avec ça, sauf à une éxception prés:

J'ai une fonction qui retourne une matrice à double tableau:
Code :
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
Array
(
    [football] => Array
        (
            [0] => Array
                (
                    [0] => Array
                        (
                            [key] => name
                            [value] => EST
                        )
 
                    [1] => Array
                        (
                            [key] => score
                            [value] => 21
                        )
 
                )
 
            [1] => Array
                (
                    [0] => Array
                        (
                            [key] => name
                            [value] => ESS
                        )
 
                    [1] => Array
                        (
                            [key] => score
                            [value] => 22
                        )
 
                    [2] => Array
                        (
                            [key] => extra
                            [value] => 1
                        )
 
                )
 
            [2] => Array
                (
                    [0] => Array
                        (
                            [key] => name
                            [value] => CSS
                        )
 
                    [1] => Array
                        (
                            [key] => faxNumber
                            [value] => 88991122
                        )
 
                )
 
        )
 
)
J'ai formaté mon WSDL de sorte à obtenir ceci en reponse à un appel webservice:
Code :
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
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:PBErMi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="urn:PB10" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Body>
      <ns1:getAccountHistory>
         <return xsi:type="ns2:TgetHistoryResponse">
            <response xsi:type="ns2:ThistoryResponse">
               <football SOAP-ENC:arrayType="ns2:Tresponse[3]" xsi:type="ns2:ThistoryContainer">
                  <item SOAP-ENC:arrayType="ns2:TresponseElement[2]" xsi:type="ns2:Tresponse">
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">name</key>
                        <value xsi:type="xsd:string">EST</value>
                     </item>
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">score</key>
                        <value xsi:type="xsd:string">21</value>
                     </item>
                  </item>
                  <item SOAP-ENC:arrayType="ns2:TresponseElement[3]" xsi:type="ns2:Tresponse">
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">name</key>
                        <value xsi:type="xsd:string">ESS</value>
                     </item>
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">score</key>
                        <value xsi:type="xsd:string">22</value>
                     </item>
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">extra</key>
                        <value xsi:type="xsd:string">1</value>
                     </item>
                  </item>
                  <item SOAP-ENC:arrayType="ns2:TresponseElement[2]" xsi:type="ns2:Tresponse">
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">name</key>
                        <value xsi:type="xsd:string">CSS</value>
                     </item>
                     <item xsi:type="ns2:TresponseElement">
                        <key xsi:type="xsd:string">faxNumber</key>
                        <value xsi:type="xsd:string">88991122</value>
                     </item>
                  </item>
               </football>
            </response>
         </return>
      </ns1:getAccountHistory>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Ceci est mon code WSDL:
Code :
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
 
<definitions name="PB" targetNamespace="urn:PB10"
	xmlns:typens="urn:PB10"
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
	xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
	xmlns="http://schemas.xmlsoap.org/wsdl/">
 
	<!-- Types  -->
 
	<types>
	    <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" 
	    	targetNamespace="urn:PB10" elementFormDefault="qualified" attributeFormDefault="qualified">
 
			<xsd:complexType name="TresponseElement">
				<xsd:all>
				  <xsd:element name="key" type="xsd:string"/>
				  <xsd:element name="value" type="xsd:string"/>
				</xsd:all>
			</xsd:complexType>
 
			<xsd:complexType name="Tresponse">
		        	<xsd:complexContent>
					<xsd:restriction base="soapenc:Array">
				    		<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:TresponseElement[]"/>
			    		</xsd:restriction>
		    		</xsd:complexContent>
		    	</xsd:complexType>
 
			<xsd:complexType name="ThistoryContainer">
		        	<xsd:complexContent>
					<xsd:restriction base="soapenc:Array">
					    	<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:Tresponse[]"/>
			    		</xsd:restriction>
		   		</xsd:complexContent>
			</xsd:complexType>
 
			<xsd:complexType name="ThistoryResponse">
				<xsd:all>
					<xsd:element minOccurs="0" maxOccurs="1" name="football" type="typens:ThistoryContainer"/>
					<xsd:element minOccurs="0" maxOccurs="1" name="basketball" type="typens:ThistoryContainer"/>
					<xsd:element minOccurs="0" maxOccurs="1" name="volleyball" type="typens:ThistoryContainer"/>
					<xsd:element minOccurs="0" maxOccurs="1" name="handball" type="typens:ThistoryContainer"/>
				</xsd:all>
			</xsd:complexType>
 
			<xsd:complexType name="TgetHistoryResponse">
				<xsd:all>
					<xsd:element minOccurs="0" maxOccurs="1" name="response" type="typens:ThistoryResponse"/>
				</xsd:all>
			</xsd:complexType>
 
		</xsd:schema>
	</types>
 
	<!-- Messages for PB Web API  -->
 
	<message name="getInput">
		<part name="key" type="xsd:string" />
		<part name="sync" type="xsd:boolean" />
		<part name="player" type="xsd:string" />
	</message>
 
	<message name="getHistoryResponse">
		<part name="return" type="typens:TgetHistoryResponse" />
	</message>
 
	<!-- Port for PB Web API -->
 
	<portType name="PB10Port">
		<operation name="getAccountHistory">
			<input message="typens:getInput" />
			<output message="typens:getHistoryResponse" />
		</operation>
	</portType>
 
 
	<!-- Binding for PB Web API - RPC, SOAP over HTTP -->
 
	<binding name="TriTuxBinding" type="typens:PB10Port">
		<soap:binding style="rpc"
			transport="http://schemas.xmlsoap.org/soap/http" />
		<operation name="getAccountHistory">
			<soap:operation soapAction="urn:PBErMi" />
			<input>
				<soap:body use="encoded" namespace="urn:PBErMi"
					encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
			</input>
			<output>
				<soap:body use="encoded" namespace="urn:PBErMi"
					encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
			</output>
		</operation>
	</binding>
 
  <!-- Endpoint for PB Web API -->
	<service name="PBService">
		<port name="PB10Port" binding="typens:TriTuxBinding">
			<soap:address location="http://localhost/PB/soapapi/"/>
		</port>
	</service>
</definitions>
En utilisant des clients de test tel que
  • soapUI (Java)
  • wsdl_client (C)
  • la classe SoapClient (php)
je n'ai pas eu de probléme pour interpreter le retour de getAccountHistory().

Le probléme est localisé avec Java et .Net, avec un client .Net, l'appel au WSDL est effectué avec succés (donc le WSDL est valide), sauf que l'appel au service getAccountHistory() genere une exception :
Citation:
Il existe une erreur dans le document XML (2, 758)
(Ligne 2, colonne 758) pointe sur
Code :
football SOAP-ENC:arrayType="ns2:Tresponse[3]" xsi:type="ns2:ThistoryContainer ...
Plus de détails sur l'exception:
Code :
{"Le type spécifié n'était pas reconnu : nom='Tresponse', espace de noms='urn:PB10' à <football xmlns=''>."}
localhost est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/08/2008, 18h23   #2
beowax
Candidat au titre de Membre du Club
 
Inscription : octobre 2004
Messages : 39
Détails du profil
Informations forums :
Inscription : octobre 2004
Messages : 39
Points : 12
Points : 12
Par défaut Réponse trouvée

Bonjour,

Je rencontre le même type de problème, avez vous trouvé une solution ?

Cordialement,
B.
beowax est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/01/2010, 16h29   #3
aomar
Invité de passage
 
Inscription : mars 2006
Messages : 7
Détails du profil
Informations forums :
Inscription : mars 2006
Messages : 7
Points : 1
Points : 1
c'est peut être trop tard , mais ça peut toujours servir
dans wsdl, quand on déclare un tableau , il faut que le nom de celui ci soit de la manière : arrayOfType
dans le cas ci-desssous la déclaration pour un tableau de TresponseElement doit être comme suit:
<xsd:complexType name="ArrayOfTresponseElement">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:TresponseElement[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
donc il y a une r^gle à suivre pour le nom à donner pour le nouveau type.
http://msdn.microsoft.com/fr-fr/library/bb469924.aspx
aomar est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 23h40.


 
 
 
 
Partenaires

Hébergement Web