PHP/SOAP : Probleme d'array of array
Bonjour à tous...
Voici mon probleme du jour.
Je construit un webservice SOAP PHP (5.2.6), qui est consommé, par un client php. Le client fonctionne dans le sens ou il envoi bien la requete formaté, au serveur, qui l'execute dans le fonction, en créant un tableau de valeur.
Mon probleme, est que le serveur ne semble pas capable de coucher le tableau de données, au format xml, pour retourner une réponse que le client sera capable de parser...
Voici le WSDL du projet :
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 104 105 106 107 108
|
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.oberon.fr"
name="Oberon_WS"
targetNamespace="http://ws.oberon.fr" >
<wsdl:types>
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://ws.oberon.fr">
<xsd:element name="Supp_Photos_Thai_Req">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="RecupListe" type="xsd:string" minOccurs="1" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Supp_Photos_Thai_Rep">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Client" minOccurs="0" maxOccurs="Unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CodeClient" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="TypeLogiciel" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="Liste" minOccurs="0" maxOccurs="1" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name="NomPhoto" type="xsd:string" minOccurs="0" maxOccurs="Unbounded" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Ajout_md5_Thai_Req">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CodeClient" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="VeCleUnik" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="NomPhoto" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="ValeurMD5" type="xsd:string" minOccurs="0" maxOccurs="1" />
<xsd:element name="TypeLogiciel" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="Ajout_md5_Thai_Rep">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ACKTraitement" type="xsd:string" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="Supp_Photos_Thai_Req">
<wsdl:part name="body" element="tns:Supp_Photos_Thai_Req"/>
</wsdl:message>
<wsdl:message name="Supp_Photos_Thai_Rep">
<wsdl:part name="body" element="tns:Supp_Photos_Thai_Rep"/>
</wsdl:message>
<wsdl:message name="Ajout_md5_Thai_Req">
<wsdl:part name="body" element="tns:Ajout_md5_Thai_Req"/>
</wsdl:message>
<wsdl:message name="Ajout_md5_Thai_Rep">
<wsdl:part name="body" element="tns:Ajout_md5_Thai_Rep"/>
</wsdl:message>
<wsdl:portType name="Oberon_WS">
<wsdl:operation name="Supp_Photos_Thai">
<wsdl:input message="tns:Supp_Photos_Thai_Req"/>
<wsdl:output message="tns:Supp_Photos_Thai_Rep"/>
</wsdl:operation>
<wsdl:operation name="Ajout_md5_Thai">
<wsdl:input message="tns:Ajout_md5_Thai_Req"/>
<wsdl:output message="tns:Ajout_md5_Thai_Rep"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Oberon_WS" type="tns:Oberon_WS">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="Supp_Photos_Thai">
<soap:operation soapAction="Oberon:Supp_Photos_Thai"/>
<wsdl:input>
<soap:body parts="body" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body parts="body" use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="Ajout_md5_Thai">
<soap:operation soapAction="Oberon:Ajout_md5_Thai"/>
<wsdl:input>
<soap:body parts="body" use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body parts="body" use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="Oberon_WS">
<wsdl:port name="Oberon_WS" binding="tns:Oberon_WS">
<soap:address location="http://ws.oberon.fr"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
Voici le code du serveur :
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
|
<?php
class Thailande{
public function Supp_Photos_Thai($data){
$RecupListe = $data->RecupListe;
include "config.inc.php";
$requete_sql_suppthai = "SELECT DISTINCT(codeclient), TypeLogiciel FROM sas_supp_photos";
$result_suppthai = mysql_query($requete_sql_suppthai);
if (false === $result_md5thai) {
$Erreur_mysql='1';
} else {
$return_values = array ('Client' => array ());
while ($codeclient = mysql_fetch_array($result_suppthai)) {
$client_return = array ('CodeClient' => $codeclient["codeclient"], 'TypeLogiciel' => $codeclient["TypeLogiciel"], 'Liste' => array ());
$requete_sql_suppthai_photos = "SELECT * FROM sas_supp_photos WHERE codeclient='".$codeclient["codeclient"]."' AND TypeLogiciel='".$codeclient["TypeLogiciel"]."'";
$result_suppthai_photos = mysql_query($requete_sql_suppthai_photos);
if (false === $result_suppthai_photos) {
$Erreur_mysql='1';
} else {
}
array_push($return_values['Client'],$client_return);
}
}
}
return $return_values;
}
}
$serversoap = new SoapServer("http://ws.oberon.fr/Thailande_photos_WS.wsdl");
try {
$serversoap->setClass("Thailande"); }
catch (Exception $f) {
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
try {
$serversoap->handle(); }
catch (Exception $f) {
}
}
?> |
Voici le code du client :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<?
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('default_socket_timeout', 1);
set_time_limit(300);
$request_values[RecupListe] = 1;
// On Créee le Client Soap
$webservice_client = new SoapClient("http://ws.oberon.fr/Thailande_photos_WS.wsdl", array('wsdl_cache' => 0, 'trace' => 1, 'exceptions' => 1, 'version'=> SOAP_1_2));
$webservice_client->__setLocation("http://ws.oberon.fr");
// On Envoi les Données
try {
$info = $webservice_client->__call("Supp_Photos_Thai", array($request_values));
print "Request :\r\n".htmlspecialchars($webservice_client->__getLastRequest()) ."\r\n"."\r\n";
print "Response:\r\n".htmlspecialchars($webservice_client->__getLastResponse())."\r\n"."\r\n";
} catch (SoapFault $f) {
echo $f;
}
?> |
Le client me gènere ce code xml :
Code:
1 2 3 4 5 6 7 8 9
|
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.oberon.cardiff.fr">
<SOAP-ENV:Body>
<ns1:Supp_Photos_Thai_Req>
<RecupListe>1</RecupListe>
</ns1:Supp_Photos_Thai_Req>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
Le serveur me gènere ce log pour ma variable $return_values :
C'est quelque part une preuve que le serveur a bien capter la requete du client, et commencer à faire le travail attendu pour hierarchiser les informations à retourner au client.
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
|
Array
(
[Client] => Array
(
[0] => Array
(
[CodeClient] => BDDY
[TypeLogiciel] => TEST
[Liste] => Array
(
[0] => Array
(
[NomPhotos] => 1-1.jpg
)
[1] => Array
(
[NomPhotos] => 2-1.jpg
)
)
)
[1] => Array
(
[CodeClient] => BDDZ
[TypeLogiciel] => TEST
[Liste] => Array
(
[0] => Array
(
[NomPhotos] => 1.jpg
)
[1] => Array
(
[NomPhotos] => 2.jpg
)
[2] => Array
(
[NomPhotos] => 3.jpg
)
)
)
[2] => Array
(
[CodeClient] => BDDT
[TypeLogiciel] => TEST2
[Liste] => Array
(
[0] => Array
(
[NomPhotos] => 1.jpg
)
)
)
)
) |
et à partir de ces données le serveur me gènere :
Code:
1 2 3 4 5 6 7 8 9
|
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.oberon.cardiff.fr">
<SOAP-ENV:Body>
<ns1:Supp_Photos_Thai_Rep>
<Client/>
</ns1:Supp_Photos_Thai_Rep>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
tandis que j'attend plutot ceci :
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
|
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.oberon.cardiff.fr">
<SOAP-ENV:Body>
<ns1:Supp_Photos_Thai_Rep>
<Client>
<CodeClient>BDDY</CodeClient>
<TypeLogiciel>TEST</TypeLogiciel>
<Liste>
<NomPhotos>1-1.jpg</NomPhotos>
<NomPhotos>2-1.jpg</NomPhotos>
</Liste>
</Client>
<Client>
<CodeClient>BDDZ</CodeClient>
<TypeLogiciel>TEST</TypeLogiciel>
<Liste>
<NomPhotos>1.jpg</NomPhotos>
<NomPhotos>2.jpg</NomPhotos>
<NomPhotos>3.jpg</NomPhotos>
</Liste>
</Client>
<Client>
<CodeClient>BDDT</CodeClient>
<TypeLogiciel>TEST2</TypeLogiciel>
<Liste>
<NomPhotos>1.jpg</NomPhotos>
</Liste>
</Client>
</ns1:Supp_Photos_Thai_Rep>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope> |
Bref,, mon soucis est que le tableau d'array d'array, ne semble pas être serialize en xml...
Quelqu'un peut t'il m'apporter ses lumieres sur ce type de construction soap svp ?
Cordialement
Tdldp