| École franco-maghrébine 2003 | WebServices | 13-17 octobre 2003 |
|
tp2c |
Contenu du fichier tp2c/tp2c.php.
<?php
// Utilisation du client SOAP de PEAR
include("SOAP/Client.php");
$client = new SOAP_Client('http://localhost:8080/axis/services/InfoCours2');
// definitions des types
require('types.php');
$salle = new Salle("Bleuet", 0, "");
$horaire = new Horaire("lundi", 23, "am");
$params = array('salle'=>$salle->__to_soap(), 'horaire'=>$horaire->__to_soap());
$options = array('namespace' => 'urn:InfoCours2', 'use'=>'encoded', 'style'=>'rpc', 'trace'=>1);
$client->_auto_translation = true;
$client->__set_type_translation('{urn:InfoCours2}Salle','Salle');
$client->__set_type_translation('{urn:InfoCours2}Horaire','Horaire');
$client->__set_type_translation('{urn:InfoCours2}Cours','Cours');
$ret = $client->call('infoCours', $params, $options);
if ( PEAR::isError($ret) ) {
print("Erreur: " . $ret->getMessage() . "<br>\n");
} else {
echo "Resultat : " . $ret->intituleCours . " donne par " . $ret->responsableCours;
}
// messages XML échangés
echo "<br><xmp>";
echo $client->wire;
echo "</xmp>";
?>
Contenu du fichier tp2c/types.php.
<?php
class Salle {
var $nomSalle = NULL;
var $numeroSalle = NULL;
var $nomBatiment = NULL;
function Salle($nom=NULL, $numero=NULL, $batiment=NULL) {
$this->nomSalle = $nom;
$this->numeroSalle = $numero;
$this->nomBatiment = $batiment;
}
function &__to_soap()
{
$inner[] =& new SOAP_Value('nomSalle','string',$this->nomSalle);
$inner[] =& new SOAP_Value('numeroSalle','int',$this->numeroSalle);
$inner[] =& new SOAP_Value('nomBatiment','string',$this->nomBatiment);
return new SOAP_Value('salle','{urn:InfoCours2}Salle',$inner);
}
}
class Horaire {
var $nomJour = NULL;
var $numeroSemaine = NULL;
var $ampm = NULL;
function Horaire($jour=NULL, $semaine=NULL, $ampm=NULL) {
$this->nomJour = $jour;
$this->numeroSemaine = $semaine;
$this->ampm = $ampm;
}
function &__to_soap()
{
$inner[] =& new SOAP_Value('nomJour','string',$this->nomJour);
$inner[] =& new SOAP_Value('numeroSemaine','int',$this->numeroSemaine);
$inner[] =& new SOAP_Value('ampm','string',$this->ampm);
return new SOAP_Value('horaire','{urn:InfoCours2}Horaire',$inner);
}
}
class Cours {
var $intituleCours = NULL;
var $responsableCours = NULL;
function Cours($intitule=NULL, $resp=NULL) {
$this->intituleCours = $intitule;
$this->responsableCours = $resp;
}
function &__to_soap()
{
$inner[] =& new SOAP_Value('intituleCours','string',$this->intituleCours);
$inner[] =& new SOAP_Value('responsableCours','string',$this->responsableCours);
return new SOAP_Value('cours','{urn:InfoCours2}Cours',$inner);
}
}
?>
| École franco-maghrébine 2003 | WebServices | 13-17 octobre 2003 |