RDV+DIAL chat illimit� dans ta r�g!
no save
Assistance
Achat
News

Forum | programmation
POO en PHP5
Nadia, le mer. 20 févr. 2008 à 20:11:35
Bonjour,
Je dois mettre en place un service web catalogue que voici:

import java.util.Hashtable;
/**
* Simple classe java qui fera office de service web ...
*/
public class ServiceCatalogue{

private Hashtable catalogue;

public ServiceCatalogue(){
catalogue = new Hashtable();
catalogue.put("java", "Sun Microsystem");
catalogue.put("eclipse", "Open Source");
catalogue.put("dotnet", "Microsoft");
catalogue.put("websphere", "IBM");
catalogue.put("WebLogic", "BEA");
catalogue.put("Langage C", "Borland");
}

public void supprimerLivre(String titre){
if (titre == null){
throw new IllegalArgumentException("Le titre doit etre renseigne.");
}
catalogue.remove(titre);
}

public void ajouterLivre(String titre, String auteur){
if ((titre == null) || (auteur == null)){
throw new IllegalArgumentException("Le titre et le nom de l'auteur doivent être renseignes.");
}
catalogue.put(titre,auteur);
}

public String trouverAuteur(String titre){
if (titre == null){
throw new IllegalArgumentException("Le titre doit etre renseigne.");
}
// Retourne l'auteur correspondant à la clé titre
return (String)catalogue.get(titre);
}

public Hashtable lister(){
return catalogue;
}
}
ce que j'ai fait en utilisant axis.
Et je dois ensuite mettre en place un service client sous nuSOAP. Pour cela, j'ai créé deux fichiers php:
ClientCatalogue.php
<?php

include('C:\Program Files\EasyPHP1-8\www\Client NuSOAP\nusoap-0.7.3\lib\nusoap.php');
//$client = new soapclient('http://localhost:8080/axis/ServiceCatalogue.jws');

class catalogue{
function lister(){
$client = new soapclient('http://localhost:8080/axis/ServiceCatalogue.jws');
$resultat = $client->call('lister');
print_r($resultat);
}

function supprimerLivre($titre){
$param = array('titre'=>$titre);
return $resultat = $client->call('supprimerLivre',$param);
}

function ajouterLivre($titre, $auteur){
$param = array('titre'=>$titre,'auteur'=>$auteur);
$resultat = $client->call('ajouterLivre',$param);
}

function trouverAuteur($titre){
$param = array('titre'=>$titre);
return $resultat = $client->call('trouverAuteur',$param);
}
}
?>
et indexCatalogue.php
<?php
require('ClientCatalogue.php');
$catalogue= new catalogue();
$catalogue->lister();

?>
C'est là que se pose mon problème.
En fait je fais le test juste pour la méthode lister(). Et ça marche. Le hic c'est que la variable $client je ne veux l'intancié qu'une seule fois et si je le fais comme vous le voyez au debut du fichier ClientCatalogue.php ben ca me genere une erreur.

Alors je me demande si vous avez une idée de la marche à suivre. Merci Configuration: Windows Vista
Internet Explorer 7.0


Nadia
févr. 08
Suivant
REPONSES
Nadia
févr. 08
kilian
févr. 08
Nadia
févr. 08
kilian
févr. 08
Nadia
févr. 08
kilian
févr. 08
Nadia
févr. 08
kilian
févr. 08
Nadia
févr. 08
Nadia
févr. 08
Version Web
Réalisé par RedShift
no save