<?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>";
我遇到了脚本问题,我第一次使用了很多这些功能。
我的问题在于$res
变量,如果我将xml
存储在$res
变量中并将其添加到SimpleXMLRequest()
中,一切正常,但如果我用$res
变量本身替换它,它失败了(没有错误,好吧,不知道如何输出错误。)
$res
输出一个XML字符串(在此处添加时,所有标签都会剥离。)
任何帮助都会很棒。