PHP如何解析 WEBSERVICES接口返回的数据
WEBSERVICE服务器,他们用.net写了个接口 http://XXX.XXX.XXX.XX/Info.asmx?wsdl
我用PHP调用这个接口
try{
$wsdl = "http://XXX.XXX.XXX.XX/Info.asmx?wsdl";
$client = new SoapClient($wsdl);
$param = array('strName'=>'吴小明', 'strIDCard'=>'4528XXXXXXXX', 'decZiparea'=>'450900');
$res = $client->GetBasicInfo($param);
print_r($res);
}catch(SOAPFault $e){
var_dump($e);
}
stdClass Object
(
[GetBasicInfoResult] => stdClass Object
(
[any] =>
<xs:schema xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="NewDataSet">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Employee" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="ID_ECERT" type="xs:decimal" minOccurs="0"/>
<xs:element name="ECERTID" type="xs:string" minOccurs="0"/>
<xs:element name="NAME" type="xs:string" minOccurs="0"/>
<xs:element name="SEX" type="xs:string" minOccurs="0"/>
<xs:element name="IDCARD" type="xs:string" minOccurs="0"/>
<xs:element name="BIRTHDAY" type="xs:dateTime" minOccurs="0"/>
<xs:element name="ECERTAREA" type="xs:string" minOccurs="0"/>
<xs:element name="FIRSTDATE" type="xs:dateTime" minOccurs="0"/>
<xs:element name="BEGINDATE" type="xs:dateTime" minOccurs="0"/>
<xs:element name="ENDDATE" type="xs:dateTime" minOccurs="0"/>
<xs:element name="GRANTORGAN" type="xs:string" minOccurs="0"/>
<xs:element name="CREDITLEVEL" type="xs:string" minOccurs="0"/>
<xs:element name="TOTALSCORE" type="xs:unsignedByte" minOccurs="0"/>
<xs:element name="TEL" type="xs:string" minOccurs="0"/>
<xs:element name="DRVLICENSE" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<DocumentElement xmlns="">
<Employee diffgr:id="Employee1" msdata:rowOrder="0">
<ID_ECERT>4507…………</ID_ECERT>
<ECERTID>4507…………</ECERTID>
<NAME>吴……</NAME>
<SEX>男性</SEX>
<IDCARD>4528…………</IDCARD>
<BIRTHDAY>1966-03-10T00:00:00+08:00</BIRTHDAY>
<ECERTAREA>道路…………</ECERTAREA>
<FIRSTDATE>2011-05-23T00:00:00+08:00</FIRSTDATE>
<BEGINDATE>2011-05-23T00:00:00+08:00</BEGINDATE>
<ENDDATE>2017-05-22T00:00:00+08:00</ENDDATE>
<GRANTORGAN>钦州市…………</GRANTORGAN>
<CREDITLEVEL>AAA级</CREDITLEVEL>
<DRVLICENSE>C1证</DRVLICENSE>
</Employee>
</DocumentElement>
</diffgr:diffgram>
)
)
SimpleXMLElement Object
(
[DocumentElement] => SimpleXMLElement Object
(
[Employee] => SimpleXMLElement Object
(
[ID_ECERT] => 4507…………
[ECERTID] => 4507…………
[NAME] => 吴……
[SEX] => 男性
[IDCARD] => 4528…………
[BIRTHDAY] => 1966-03-10T00:00:00+08:00
[ECERTAREA] => 道路…………
[FIRSTDATE] => 2011-05-23T00:00:00+08:00
[BEGINDATE] => 2011-05-23T00:00:00+08:00
[ENDDATE] => 2017-05-22T00:00:00+08:00
[GRANTORGAN] => 钦州市…………
[CREDITLEVEL] => AAA级
[DRVLICENSE] => C1证
)
)
)