【发布时间】:2012-04-20 02:22:12
【问题描述】:
我需要访问 .NET Web 服务的响应,该服务以 XML 格式返回数据。 如何拆分返回的数据?例如,我想将数据解析成一些 PHP 变量:
$name = "Dupont";
$email = "charles.dupont@societe.com";
我一直在寻找如何做到这一点,但没有找到正确的方法。
我的脚本是:
$result = $client->StudentGetInformation($params_4)->StudentGetInformationResult;
echo "<p><pre>" . print_r($result, true) . "</pre></p>";
我页面中的回声是:
stdClass Object
(
[any] => 0Successful10371DupontCharlescharles.dupont@societe.com1234charles.dupont@societe.comfalsefr-FR1003FIRST FINANCE1778AAA Département
)
webservice响应格式为:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<StudentGetInformationResponse xmlns="http://tempuri.org/">
<StudentGetInformationResult>xml</StudentGetInformationResult>
</StudentGetInformationResponse>
</soap:Body>
</soap:Envelope>
我已经尝试过您的示例。但它不能满足我的需要。 我需要拆分返回的值。我想获取数据并将它们放入 PHP 变量中:
$name = "杜邦"; $email = "charles.dupont@societe.com"; 等等……
不幸的是,你的例子的回声给出了:
object(stdClass)#1 (1) { ["StudentGetInformationResult"]=> object(stdClass)#11 (1) { ["any"]=> string(561) "0Successful10371DupontCharlescharles.dupont@societe.com1234charles.dupont@societe.comfalsefr-FR1003FIRST FINANCE1778AAA Département" } }
【问题讨论】:
-
SoapClientphp.net/manual/en/class.soapclient.php 像魅力一样工作 -
谢谢...但是你知道我必须使用哪个类吗?
标签: php .net xml web-services soap