1 pièce(s) jointe(s)
Retour en UTF-8 à la place d'un XML
Bonjour, j'ai déjà posté une question sur un problème qui a été résolu depuis, mais je me retrouve face à un nouveau (et dernier) problème, je reçois une exception car d'après l'erreur je reçois de l'UTF-8 au lieu de recevoir un XML mais je ne comprend pas d'où peut provenir l’erreur.
Voici donc l'erreur :
Pièce jointe 299982
Et je vous joint aussi mon WSDL (test.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
| <?xml version="1.0" encoding="iso-8859-1"?>
<wsdl:definitions
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
targetNamespace="urn:serviceTestwsdl"
xmlns:tns="urn:serviceTestwsdl"
>
<types>
<xsd:schema targetNamespace="urn:serviceTestwsdl">
<xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" />
<xsd:complexType name="User">
<xsd:all>
<xsd:element name="id" type="xsd:int"/>
<xsd:element name="nom" type="xsd:string"/>
</xsd:all>
</xsd:complexType>
</xsd:schema>
</types>
<message name="getUserByIdRequest">
<part name="id" type="xsd:int" />
</message>
<message name="getUserByIdResponse">
<part name="return" type="tns:User" />
</message>
<wsdl:portType name="serviceTestPortType">
<wsdl:operation name="getUserById">
<documentation>Récupère un utilisateur en fonction de son ID</documentation>
<input message="tns:getUserByIdRequest"/>
<output message="tns:getUserByIdResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="serviceTestBinding" type="tns:serviceTestPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUserById">
<soap:operation soapAction="urn:serviceTestwsdl#getUserByIdServeur" style="rpc"/>
<wsdl:input>
<soap:body use="encoded" namespace="urn:serviceTestwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="urn:serviceTestwsdl" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="serviceTest">
<wsdl:port name="serviceTestPort" binding="tns:serviceTestBinding">
<soap:address location="http://localhost/testSolution/testSolution.php"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions> |
Ainsi que mon php (testSolution.php)
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
| <?php
class User
{
private $id = 0;
private $nom = null;
public function User($id = 0, $nom = null)
{
$this->id = $id;
$this->nom = $nom;
}
public function getId() {return $this->id;}
public function getNom() {return $this->nom;}
public function setId($id) {$this->id = $id;}
public function setNom($nom) {$this->nom = $nom;}
}
class Ws
{
public $pdo = null;
public $adresse = null;
public function Ws()
{
$parametres = parse_ini_file("param/param.ini");
$this->pdo = new PDO(
$parametres['dsn'],
$parametres['user'],
$parametres['psw'],
array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
);
$self = $_SERVER["PHP_SELF"];
$add = explode("/",$self);
$this->adresse = "http://".$_SERVER["HTTP_HOST"]."/".$add[1]."/";
}
function getUserById($id){
$user = new User();
$sql = "SELECT * FROM utilisateurs WHERE id ='".$id."'";
$requete = $this->pdo->prepare($sql);
if ($requete->execute()) {
while($donnees = $requete->fetch()) {
$user->setId($donnees['ID']);
$user->setNom($donnees['NOM']);
$liste[] = $user;
}
}
return $liste;
}
}
ini_set("soap.wsdl_cache_enabled", 0);
$serversoap = new SoapServer("http://localhost/testSolution/test.wsdl");
$serversoap->setClass("Ws");
$serversoap->handle();
?> |
Merci d'avance ☻♥