首页 > 后端开发 > php教程 > PHP怎么解析 WEBSERVICES接口返回的数据

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

WBOY
发布: 2016-06-13 12:33:30
原创
1049 人浏览过

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怎么拿出这些值呢?

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板