Bonjour,
J'essaie de créer un client SOAP en PHP, mais j'ai des problêmes avec les namespaces.
En effet, un client créé en C# envoie une un message comme celui-ci:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://content.tripadvisor.com" xmlns:api="http://api.content.tripadvisor.com">
<soapenv:Header/>
<soapenv:Body>
<con:getHotel>
<con:in0>
<api:TAID>111111</api:TAID>
<api:clientLoginID>DQSLKVDV47544QDS5C4DQ5V1Q2D</api:clientLoginID>
<api:maxUserReviewSummaries>10</api:maxUserReviewSummaries>
<api:maxUserReviews>20</api:maxUserReviews>
</con:in0>
</con:getHotel>
</soapenv:Body>
</soapenv:Envelope>
Et bien sûr elle fonctionne très bien.
Mais lorsque j'essaie de le faire en PHP, le message SOAP généré est le suivant:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="node_namespace"
xmlns:ns2="http://content.tripadvisor.com">
<SOAP-ENV:Body>
<ns2:getHotel>
<TAID>
111111
</TAID>
<clientLoginID>
DQSLKVDV47544QDS5C4DQ5V1Q2D
</clientLoginID>
<startUserReviewID>
0
</startUserReviewID>
<userReviewOffset>
0
</userReviewOffset>
<userReviewSortOrder>
0
</userReviewSortOrder>
<userReviewSummaryOffset>
0
</userReviewSummaryOffset>
</ns2:getHotel>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
On s'aperçoit qu'il manque un noeud sous GetHotel, ainsi que le namespace des différentes propriétés.
Voici le code PHP:
<?php
//header("Content-Type: text/xml; charset=UTF-8");
// lier le client au fichier WSDL
class SOAPStruct {
function SOAPStruct()
{
$this->TAID = 111111;
$this->clientLoginID = "DQSLKVDV47544QDS5C4DQ5V1Q2D";
$this->startUserReviewID = 0;
$this->userReviewOffset = 0;
$this->userReviewSortOrder = 0;
$this->userReviewSummaryOffset = 0;
}
}
$client = new SoapClient("http://content.tripadvisor.com/ContentServiceV2?wsdl");
$struct = new SOAPStruct();
$soapstruct = new SoapVar($struct, SOAP_ENC_OBJECT,null,null,"getHotel","node_namespace");
//try{
$client->getHotel(new SoapParam($soapstruct, "HotelOptions"));
/*}catch(Exception $e){
echo $e->getMessage();
}*/
try{
print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
}catch(Exception $e){
echo $e->getMessage();
}
?>
Mais je ne sais pas comment faire pour lui préciser le namespace, ainsi que le noeud manquant.
merci de votre aide.