2012-08-02 28 views
0

使用我的web服务,我想在一个XML来保存文件,该文件显示给我的反应,但是当我试图挽救这个数据则显示MZE错误:函数Php fwrite的给出提示信息错误

这里是我得到的错误:

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 

我使用的代码是那里;但我不知道我知道响应是XML,但是ID不保存在我想要的文件中,我不知道为什么,只是因为它不是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); 

?> 

回答

1

该消息来自行:

$texte=$client->GetData($o); 
echo $texte; 

GetData不返回字符串,但一个stdClass代替,这是不能被转换为字符串。 var_dump($texte)以查看它返回的内容,并回显stdClass的相应属性。

编辑:我查了WDSL并检查; GetData()函数返回一个GetDataResponse,它似乎包含一个属性GetDataResult(一个字符串)。所以下面应该工作:

$texte=$client->GetData($o); 
echo $texte->GetDataResult; 
+0

非常感谢你的帮助。 我有一个标准的问题:在我的PHP页面显示我我如何删除它? – 2012-08-02 08:25:20

+0

@StanislasPiotrowski这看起来像一个BOM字符。使用一个体面的PHP编辑器并将您的文件保存为UTF-8,无需BOM。 – 2012-08-02 08:27:09

+0

thnaks所有。这对我来说非常有帮助 – 2012-08-02 08:29:28