Reputation: 2694
Using my webservice I would like to save in a XML file the response that it display to me, but when I'm trying to save this data it displays mze an error:
here is the error I get:
Catchable fatal error: Object of class stdClass could not be converted to string in C:\wamp\www\NEOGETCASH\GESTIONNAIRE\DOSSIERS\creditsafe.php on line 13
the code I'm using is there; but I don't know I know that the response is as XML, but id doesn't save in the file I wanted I don't know why, just because it is not a varchar
.
<?php
$wsdl = "https://www.creditsafe.fr/getdata/service/CSFRServices.asmx?WSDL";
$client = new SoapClient($wsdl);
$debiteur_siret = "<xmlrequest><header><username>demo</username><password>**********</password><operation>getcompanyinformation</operation><language>FR</language><country>FR</country><chargereference></chargereference></header><body><package>standard</package><companynumber>40859907400049</companynumber></body>
</xmlrequest> " ;
$o = new stdClass();
$o->requestXmlStr = $debiteur_siret;
$fichier =
//header('Content-Type: text/xml');
$texte=$client->GetData($o);
echo $texte;
$fp = fopen("tmp/".$_GET['n_doss'].".xml", "w+");
//fwrite($fp, $texte);
fclose($fp);
?>
Upvotes: 0
Views: 523
Reputation: 18859
The message comes from the lines:
$texte=$client->GetData($o);
echo $texte;
GetData
does not return a string, but a stdClass
instead, which can not be converted to a string. var_dump($texte)
to see what it returns, and echo the appropriate property of the stdClass
.
EDIT: I've looked up the WDSL and checked; the GetData()
function returns a GetDataResponse
, which seems to contain a property GetDataResult
(a string). So the following should work:
$texte=$client->GetData($o);
echo $texte->GetDataResult;
Upvotes: 1