Parsing SOAP response

前端 未结 2 654
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 13:12

Calling a web service from my controller:

$client = new \\SoapClient(\"http://.../webservice/NAME_OF_PAGE.asmx?WSDL\");
$result = $client->EstadoHabitacio         


        
2条回答
  •  天命终不由人
    2020-12-30 13:42

    Complete Reference Code To Soap Response XML File Here How To parse we will see in below example code

    
        
            
                
                    
                        
                            
                                
                                    
                                        
                                            
                                                
                                                    
                                                    
    
                                                    
                                                    
                                                
                                            
                                        
                                    
                                
                            
                        
                        
                            
                                1Ahmedabad23.04583972.550578
    21Amritsar31.70560374.807337

    using this code you can easily get all the Tables data in $title variable and using that you can easily get any specific value easily...

        'USENAME','Password'=>'PASSWORD','UserCode'=>'1991');
            $wsdl = 'http://SITENAME.com/service.asmx?WSDL';
            try {
    
                $soap = new SoapClient($wsdl);
                $header = new SoapHeader('http://tempuri.org/', 'AuthHeader', $apiauth);
                $soap->__setSoapHeaders($header);   
                $data = $soap->methodname($header);
            }
            catch(Exception $e) {
                die($e->getMessage());
            }
            // echo "
    ";
            // print_r($data->xyzResult->any);
            $response = $data->xyzResult->any;
            $sxe = new SimpleXMLElement($response);
            $sxe->registerXPathNamespace('d', 'urn:schemas-microsoft-com:xml-diffgram-v1');
            $result = $sxe->xpath("//NewDataSet");
            echo "
    ";
            foreach ($result[0] as $title) {
                print_r($title);
            }
            die;
        ?>
    

提交回复
热议问题