draxq02664 2016-08-31 06:40
浏览 21

SimpleXMLRequest的问题与包含xml的变量失败

<?php
$wsdl = 'http://blahblah/Service.asmx?WSDL';
$params = array('customerCode'=>'11111');
$options = array(
    'uri'=>'http://schemas.xmlsoap.org/soap/envelope/',
    'style'=>SOAP_RPC,
    'use'=>SOAP_ENCODED,
    'soap_version'=>SOAP_1_1,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'connection_timeout'=>15,
    'trace'=>true,
    'encoding'=>'UTF-8',
    'exceptions'=>true,
);
try {
    $soap = new SoapClient($wsdl, $options);
    $data = $soap->GetCustomerAccountList($params);
}
catch(Exception $e) {
    die($e->getMessage());
}
echo "String Dump<br>";
$res = $soap->__getLastResponse();
echo $res;
echo "<br>";
echo "<br>";
$user = new SimpleXMLElement('<?xml version="1.0"?><Response><Status code="201" text="Accepted" /><ResultList count="1"><Address addressID="XXXX"><Name>XXXXX</Name><PostalAddress><Street>XXXXXX</Street><City>XXXX</City><State>VIC</State><PostalCode>3175</PostalCode><Country>Australia</Country></PostalAddress><Phone name="Office"><TelephoneNumber><Number>XXXX</Number></TelephoneNumber></Phone><TaxDetail percentageRate="10.00">01</TaxDetail></Address></ResultList></Response>');
echo $user->ResultList->Address->Name;
echo "<br>";
echo $user->ResultList->Address->PostalAddress->Street;
echo "<br>";

I'm having problems with a script, first time I'm using a lot of these features.

My issue is with the $res variable, if I take the xml stored in the $res variable and add it inside SimpleXMLRequest(), everything works fine, but if I replace it with the $res variable itself, it fails (no error, well, not sure how to output an error anyway.) $res outputs an XML string (all the tags strip when adding it here.)

Any help would be great.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测