Rumah >pembangunan bahagian belakang >tutorial php > PHP怎么解析 WEBSERVICES接口返回的数据

PHP怎么解析 WEBSERVICES接口返回的数据

WBOY
WBOYasal
2016-06-13 12:33:301054semak imbas

PHP如何解析 WEBSERVICES接口返回的数据
WEBSERVICE服务器,他们用.net写了个接口 http://XXX.XXX.XXX.XX/Info.asmx?wsdl
我用PHP调用这个接口 

<br />
try{<br />
	$wsdl = "http://XXX.XXX.XXX.XX/Info.asmx?wsdl";<br />
	$client = new SoapClient($wsdl);<br />
	$param = array('strName'=>'吴小明', 'strIDCard'=>'4528XXXXXXXX', 'decZiparea'=>'450900');<br />
	$res = $client->GetBasicInfo($param);<br />
	print_r($res);<br />
}catch(SOAPFault $e){<br />
	var_dump($e);<br />
}<br />

得到如下结果:
<br />
<br />
stdClass Object<br />
(<br />
    [GetBasicInfoResult] => stdClass Object<br />
        (<br />
            [any] => <br />
			<br />
				<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet"><br />
				  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Employee" msdata:UseCurrentLocale="true"><br />
				  <xs:complexType><br />
					<xs:choice minOccurs="0" maxOccurs="unbounded"><br />
					  <xs:element name="Employee"><br />
					  <xs:complexType><br />
						<xs:sequence><br />
						  <xs:element name="ID_ECERT" type="xs:decimal" minOccurs="0"/><br />
						  <xs:element name="ECERTID" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="NAME" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="SEX" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="IDCARD" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="BIRTHDAY" type="xs:dateTime" minOccurs="0"/><br />
						  <xs:element name="ECERTAREA" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="FIRSTDATE" type="xs:dateTime" minOccurs="0"/><br />
						  <xs:element name="BEGINDATE" type="xs:dateTime" minOccurs="0"/><br />
						  <xs:element name="ENDDATE" type="xs:dateTime" minOccurs="0"/><br />
						  <xs:element name="GRANTORGAN" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="CREDITLEVEL" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="TOTALSCORE" type="xs:unsignedByte" minOccurs="0"/><br />
						  <xs:element name="TEL" type="xs:string" minOccurs="0"/><br />
						  <xs:element name="DRVLICENSE" type="xs:string" minOccurs="0"/><br />
						</xs:sequence><br />
					  </xs:complexType><br />
					  </xs:element><br />
					</xs:choice><br />
				  </xs:complexType><br />
				  </xs:element><br />
				</xs:schema><br />
				<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"><br />
				  <DocumentElement xmlns=""><br />
					<Employee diffgr:id="Employee1" msdata:rowOrder="0"><br />
					  <ID_ECERT>4507…………</ID_ECERT><br />
					  <ECERTID>4507…………</ECERTID><br />
					  <NAME>吴……</NAME><br />
					  <SEX>男性</SEX><br />
					  <IDCARD>4528…………</IDCARD><br />
					  <BIRTHDAY>1966-03-10T00:00:00+08:00</BIRTHDAY><br />
					  <ECERTAREA>道路…………</ECERTAREA><br />
					  <FIRSTDATE>2011-05-23T00:00:00+08:00</FIRSTDATE><br />
					  <BEGINDATE>2011-05-23T00:00:00+08:00</BEGINDATE><br />
					  <ENDDATE>2017-05-22T00:00:00+08:00</ENDDATE><br />
					  <GRANTORGAN>钦州市…………</GRANTORGAN><br />
					  <CREDITLEVEL>AAA级</CREDITLEVEL><br />
					  <DRVLICENSE>C1证</DRVLICENSE><br />
					</Employee><br />
				  </DocumentElement><br />
				</diffgr:diffgram><br />
			<br />
        )<br />
<br />
)<br />


[any] => 后面不像是个标准的XML。请问,用PHP怎么拿出这些值呢?

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn