phpClient返回嵌套XML

时间:2017-07-18 13:24:25

标签: php soap soap-client soapserver

我已经使用肥皂从webservice返回数据:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
   <soap-env:Header/>
   <soap-env:Body>
      <n0:ZFIFM_VIRTUAL_ACCOUNTResponse xmlns:n0="urn:sap-com:document:sap:rfc:functions">
         <BILLDETAILS>
            <item>
               <BILLCODE>?</BILLCODE>
               <BILLNAME>?</BILLNAME>
               <BILLSHORTNAME>?</BILLSHORTNAME>
               <BILLAMOUNT>?</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>01</BILLCODE>
               <BILLNAME>BIL</BILLNAME>
               <BILLSHORTNAME>Billing</BILLSHORTNAME>
               <BILLAMOUNT>114509000</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>02</BILLCODE>
               <BILLNAME>TAX</BILLNAME>
               <BILLSHORTNAME>PPN 10%</BILLSHORTNAME>
               <BILLAMOUNT>11450900</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>03</BILLCODE>
               <BILLNAME>TAX</BILLNAME>
               <BILLSHORTNAME>PPL WAPU</BILLSHORTNAME>
               <BILLAMOUNT>11450900</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>04</BILLCODE>
               <BILLNAME>TAX</BILLNAME>
               <BILLSHORTNAME>PPK 4.2</BILLSHORTNAME>
               <BILLAMOUNT>6758400</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>05</BILLCODE>
               <BILLNAME>TAX</BILLNAME>
               <BILLSHORTNAME>PPJ 23 - 2%</BILLSHORTNAME>
               <BILLAMOUNT>193500</BILLAMOUNT>
            </item>
            <item>
               <BILLCODE>06</BILLCODE>
               <BILLNAME>TAX</BILLNAME>
               <BILLSHORTNAME>PPO 23 - 15%</BILLSHORTNAME>
               <BILLAMOUNT>5587500</BILLAMOUNT>
            </item>
         </BILLDETAILS>
         <BILLINFO1>1000000014</BILLINFO1>
         <BILLINFO2>YOU MEAN IT</BILLINFO2>
         <BILLINFO3>1140000000</BILLINFO3>
         <BILLINFO4>JOJO Heart</BILLINFO4>
         <CURRENCY>360</CURRENCY>
         <STATUS>
            <item>
               <ISERROR>?</ISERROR>
               <ERRORCODE>?</ERRORCODE>
               <STATUSDESCRIPTION>?</STATUSDESCRIPTION>
            </item>
            <item>
               <ISERROR>false</ISERROR>
               <ERRORCODE>00</ERRORCODE>
               <STATUSDESCRIPTION>Success</STATUSDESCRIPTION>
            </item>
         </STATUS>
      </n0:ZFIFM_VIRTUAL_ACCOUNTResponse>
   </soap-env:Body>
</soap-env:Envelope>

问题是当我使用此方法调用BILLDETAILS时,如何获取soapCLient数组:

$x = $client->ZFIFM_VIRTUAL_ACCOUNT(array("BILLKEY1"=>"8871711140100014"));

我已尝试使用count($x->BILlDETAILS),但它只返回1个值,当我回复时:echo $x->BILLDETAILS[0]; 它打印空白..

我需要一个建议.. 感谢..

1 个答案:

答案 0 :(得分:0)

试试这样:

foreach ($x->BILLDETAILS->item as $key => $item) {
    var_dump($item);
}