Cómo recuperar xml de mi servicio web en php

I'm using a webservice in php here :


You can test for example getListing con idModule = dafda774-317d-4b5f-bb8b-33e5977dc13c, Y haga clic en invoke

I'm trying to retrieve this result (XML) in php. But i have no idea how to do this.

If i use getListing like :

$client = new SoapClient("http://cdt33.tourinsoft.com/soft/RechercheDynamique/Syndication/controle/syndication2.asmx?wsdl");

$getListing = $client->getListing(
    array (
        'idModule' => "dafda774-317d-4b5f-bb8b-33e5977dc13c"));

Result is something like that :

stdClass Object
    [getListingResult] => stdClass Object
            [schema] => 
            [any] => 
HOTAQU03301V3EZB2005-06-29T00:00:00.0000000+02:002012-06-28T14:43:44.0000000+02:0074HOTHôtellerie1e9eb500-e0c9-4a53-b6a5-0b36faa63ed4true 2 étoiles Français www.hotel-lenovel.com +33 5 57 52 26 47 7 oui En centre ville$ Au bord de la mer Ascenseur$ Salon 22 -1.164866 Au coeur d'Arcachon, à deux pas de la gare, du théâtre de l'Olympia et de l'Office du Tourisme, le Novel bénéficie d'une situation privilégiée. Les chambres sont chaleureuses et douillettes pour un séjour....... ETC

How can i retieve XML ?? Thanks you !

preguntado el 31 de julio de 12 a las 15:07

Check the API docs to see if it has an xml output mode? -

3 Respuestas

Here is sometihng to try out, run it and check the source code for the page, it should contain the xml file. SOAP is just a fancy way of doing a post.

function smartpost($type,$host,$port='80',$path='/',$data='') {
    $_err = 'lib sockets::'.__FUNCTION__.'(): ';
    switch($type) { case 'http': $type = ''; case 'ssl': continue; default: die($_err.'bad $type'); } if(!ctype_digit($port)) die($_err.'bad port');
    if(!empty($data)) foreach($data AS $k => $v) $str .= urlencode($k).'='.urlencode($v).'&'; $str = substr($str,0,-1);

    $fp = fsockopen($host,$port,$errno,$errstr,$timeout=30);
    if(!$fp) die($_err.$errstr.$errno); else {
        fputs($fp, "POST $path HTTP/1.1\r\n");
        fputs($fp, "Host: $host\r\n");
        fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
        fputs($fp, "Content-length: ".strlen($str)."\r\n");
        fputs($fp, "Connection: close\r\n\r\n");
        fputs($fp, $str."\r\n\r\n");

        while(!feof($fp)) $d .= fgets($fp,4096);
        $result = explode("\r\n\r\n", $d, 2);

        $header = isset($result[0]) ? $result[0] : '';
        $content = isset($result[1]) ? $result[1] : '';

    } return array($header, $content);

list($header, $content) = smartpost('http','cdt33.tourinsoft.com','80','/soft/RechercheDynamique/Syndication/controle/syndication2.asmx/getListingByIDs',array('idModule'=>'dafda774-317d-4b5f-bb8b-33e5977dc13c','ObjetTourCode' => '','IDs' => ''));

Respondido 31 Jul 12, 17:07

I have this error : Warning: fsockopen() [function.fsockopen]: unable to connect to cdt33.tourinsoft.com/soft/RechercheDynamique/Syndication/… (Unable to find the socket transport "http" - did you forget to enable it when you configured PHP?), and fsockopen is enable. - clement andraud

@ClémentAndraud , I don't have anything to test it on and like I said it has been a couple years, but I think I fixed the error you were getting. - gmlima

No, the result is juste an empty html page. - clement andraud

@ClémentAndraud Try running it in a from this: <?php error_reporting(E_ALL); ini_set("display_errors", 1); include("test.php"); ?> where test.php is the name of the file. And check for errors in the result or in the logs. - gmlima

@ClémentAndraud alright, I tested this one out, just look at the source code for the resulting webpage, your xml will be stored in the $content variable. - gmlima

assuming you are using standard PHP SoapClient, try using


(http://www.php.net/manual/en/soapclient.getlastresponse.php) According to maual, you should also set trace option to true on SoapClient:

$client = new SoapClient("http://cdt33.tourinsoft.com/soft/RechercheDynamique/Syndication/controle/syndication2.asmx?wsdl", array('trace' => true));

Regards, Jakub Derda

Respondido 31 Jul 12, 17:07

class ABRSoapClient extends SoapClient {

$result = "";

function __doRequest($request, $location, $action, $version) 

    $result =  parent::__doRequest($request, $location, $action, $version); 
    return $result;



Instead of creating object of SoapClient, Create object of ABRSoapClient, Here $result is your XML string from Web-Service.

You can access that variable using $client->result;

Respondido 01 ago 12, 07:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.