Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 07/12/2007, 17h03   #1
Membre du Club
 
Inscription : mai 2006
Messages : 210
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 210
Points : 67
Points : 67
Par défaut [SOAP] tableau associatif --> tableau d'objets

Bonjour,

je recupere de la fonction "$client->__soapCall" :
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
 
stdClass Object
(
    [return] => Array
        (
            [0] => stdClass Object
                (
                    [dateDebut] => 2007-12-10T00:00:00+01:00
                    [dateFin] => 2007-12-11T00:00:00+01:00
                    [nbDispo] => 23
                    [nbJours] => 1
                    [prestation] => stdClass Object
                        (
                            [code-] => C1        
                            [codeFamille] => 1
                            [libelle] => Chambre 1 grand lit           
                        )
 
                    [tarifMax] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                    [tarifMin] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                    [tarifPeriode] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                )
 
            [1] => stdClass Object
                (
                    [dateDebut] => 2007-12-10T00:00:00+01:00
                    [dateFin] => 2007-12-11T00:00:00+01:00
                    [nbDispo] => 2
                    [nbJours] => 1
                    [prestation] => stdClass Object
                        (
                            [c-ode] => C2        
                            [codeFamille] => 1
                            [libelle] => Chambre 2 petits lits         
                        )
 
                    [tarifMax] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                    [tarifMin] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                    [tarifPeriode] => stdClass Object
                        (
                            [codeDevise] => eur
                            [montant] => 42
                        )
 
                )
        )
 
)
et j'aimerais obtenir un tableau de Dispo (objet principal) contenant une Prestation et des Tarifs.

Y a t il une fonction d'introspecton ou autre methode permetant de faire le mapping entre le tableau associatif et mes objets ?

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
 
class Dispo{
 
	/** @var Prestation */
	public $prestation;
 
	/** @var string */
	public $nbDispo;
 
	/** @var Tarif[] */
	public $tarifPeriode; 
 
	/** @var Tarif */
	public $tarifMin;
 
	/** @var Tarif */
	public $tarifMax;
 
	/** @var string */
	public $dateDebut;
 
	/** @var string */
	public $dateFin;
 
	/** @var string */
	public $nbJours;
Code :
1
2
3
4
5
6
7
class Tarif{
 
	/** @var string */
	public $montant;
 
	/** @var string */
	public $devise;
Code :
1
2
3
4
5
6
7
8
9
10
class Prestation{
 
	/** @var string */
	public $code;
 
	/** @var string */
	public $libelle;
 
	/** @var string */
	public $codeFamille;
mickael.guilbert est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/01/2008, 18h05   #2
Membre du Club
 
Inscription : mai 2006
Messages : 210
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 210
Points : 67
Points : 67
il faut utiliser classmap

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
 
// ACTION WS
$sbWsdl = $properties->getProperty('hotel.webServices.hotel.wsdl');
$sbClassmap = array();
$tmpClient = new SoapClient($sbWsdl,Array(	'trace' 		=> 1,
					'login'     	=> "xxx", 
    				'password'   	=> "xxx",
    				'trace'      	=> 1, 
    				'exceptions' 	=> 0));
 
foreach($tmpClient->__getTypes() as $type){
	$array = split(" ", $type);
    if($array[0] == "struct" && class_exists($array[1]))    {
        $classmap[$array[1]] = $array[1];
    }
}
unset($tmpClient);
 
$sbOptions = Array(	'trace' 		=> 1,
					'classmap' 		=> $sbClassmap,
					'login'     	=> "xxx", 
    				'password'   	=> "xxx",
    				'trace'      	=> 1, 
    				'exceptions' 	=> 0);
 
 
$client = new SoapClient($sbWsdl,$sbOptions);
 
/////////////////////////////////////////////////////////////////////////////////////////////////////
echo "<hr/> <strong>GETDISPO(hotel,'$__debut','$__fin')</strong><br/>";
 
$param = array(array(
  "hotelId" => $__hotel,
  "dateDebutDDMMYYYY"  => $__debut,
  "dateFinDDMMYYYY" => $__fin
  ));
 
$response = $client->__soapCall("getDispos", $param);
 
foreach ($response->return as $dispo){ ....
mickael.guilbert est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 16h35.


 
 
 
 
Partenaires

Hébergement Web