Trouble Parsing SOAP response in PHP using simplexml

后端 未结 1 646
再見小時候
再見小時候 2021-01-15 20:40

I\'m using cURL to POST a SOAP request. The response is as follows:




        
相关标签:
1条回答
  • 2021-01-15 21:01

    Variable and property names are case sensitive and while I was testing it, it turned out there's other stuff as well. The following works:

    $soap = $xml->children($ns['env']);
    $getaddressresponse = $soap->Body->children($ns['ns2']);
    foreach ($getaddressresponse->getLocationForGroupResponse->children($ns['ns2']) as $item)
    {
        $item = $item->children();
        echo $item->address . '<br />';
    }
    

    To answer the updated question:

    $fault = $soap->Body->children($ns['env']);
    if (isset($fault->Fault))
    {
        // Handle error
    }
    
    0 讨论(0)
提交回复
热议问题