我有一个奇怪的问题。我正在使用SOAP for PHP并获取价格。
如果我使用SoapUI获取价格,响应将如下所示:
<article>
<id>53db51:f984db9fa4:-773c</id>
<primaryid>BG267</primaryid>
<isremoved>false</isremoved>
<articlecampaignprice>
<currency>NOK</currency>
<price>340.0</price>
</articlecampaignprice>
</article>
但是,如果我在PHP中做同样的事情,我得到的答案是:
object(stdClass)#81 (1) {
["article"]=>
array(3) {
[0]=>
object(stdClass)#82 (4) {
["id"]=>
string(23) "53db51:f984db9fa4:-773c"
["primaryid"]=>
string(5) "BG267"
["isremoved"]=>
bool(false)
["articlecampaignprice"]=>
object(stdClass)#83 (0) {
}
}
}
}
“articlecampaignprice” - 对象是空的。 PHP中是否有任何可能导致这种情况的设置?我已经将WSDL-Cache设置为0.
答案 0 :(得分:0)
试试这个
<?php
$xmlData = "<article>
<id>53db51:f984db9fa4:-773c</id>
<primaryid>BG267</primaryid>
<isremoved>false</isremoved>
<articlecampaignprice>
<currency>NOK</currency>
<price>340.0</price>
</articlecampaignprice>
</article>";
$xml=simplexml_load_string($xmlData) or die("Error: Cannot create object");
echo "<pre>";
print_r($xml);
?>
输出
SimpleXMLElement Object
(
[id] => 53db51:f984db9fa4:-773c
[primaryid] => BG267
[isremoved] => false
[articlecampaignprice] => SimpleXMLElement Object
(
[currency] => NOK
[price] => 340.0
)
)
答案 1 :(得分:-1)
webservice的所有者重新启动了服务器。现在它再次正常工作。奇怪。
结论:问题不在于PHP方面。这是外部Web服务。