我一直在使用CURL和PHP进行SOAP请求/响应,但是我似乎无法弄清楚如何在生命中提取数据。
SOAP请求的脚本
$soapUrl = "https://xml.proveid.experian.com/IDSearch.cfc?wdsl";
// xml post structure
$xml_post_string = "<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:cor='http://corpwsdl.oneninetwo'>
<soapenv:Header/>
<soapenv:Body>
<cor:search soapenv:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
<xml xsi:type='xsd:string'><![CDATA[
<Search xmlns:xsd='https://xml.proveid.experian.com/xsd/Search.xsd'>
<Authentication>
<Username>".$user."</Username>
<Password>".$pw."</Password>
</Authentication>
<CountryCode>GBR</CountryCode>
<Person>
<Name>
<Forename>".$firstName."</Forename>
<Surname>".$secondName."</Surname>
</Name>
<DateOfBirth>".$dob."</DateOfBirth>
</Person>
<Addresses>
<Address Current='1'>
<Premise>".$premise."</Premise>
<Street>".$streetName."</Street>
<PostTown>".$postTown."</PostTown>
<Region/>
<Postcode>".$postCode."</Postcode>
<CountryCode>GBR</CountryCode>
</Address>
</Addresses>
<Telephones>
<Telephone>
<Number>".$telephone."</Number>
</Telephone>
</Telephones>
<IPAddress>127.0.0.1</IPAddress>
<Emails>
<Email>".$email."</Email>
</Emails>
<SearchOptions>
<ProductCode>".$product."</ProductCode>
</SearchOptions>
</Search>]]>
</xml>
</cor:search>
</soapenv:Body>
</soapenv:Envelope>";
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: https://xml.proveid.experian.com/IDSearch.cfc",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
// PHP cURL for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 100);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// converting
$response = curl_exec($ch);
curl_close($ch);
print_r($response);`
响应
<Search xmlns:xsd="https://xml.proveid.experian.com/xsd/Search.xsd">
<CountryCode>GBR</CountryCode>
<Person>
<Name><Forename>Baken</Forename>
<Surname>Jorure</Surname>
</Name>
<DateOfBirth>1989-09-09</DateOfBirth>
<Age>26</Age>
</Person>
<Addresses>
<Address Current="1">
<Premise>410</Premise>
<Street>Beuno Terrace</Street>
<PostTown>Beuno</PostTown>
<Region/>
<Postcode>LL545BT</Postcode>
<CountryCode>GBR</CountryCode>
</Address>
</Addresses>
<Telephones>
<Telephone>
<Number>01154567892</Number>
</Telephone>
</Telephones>
<IPAddress>127.0.0.1</IPAddress>
<Emails>
<Email>bakenjorure@www.com</Email>
</Emails>
<SearchOptions>
<ProductCode>ProveID</ProductCode>
</SearchOptions>
<OurReference>B3C369C0-F001-4FB1-80D3-801CB9D872FE</OurReference>
<SearchDate>2015-10-09T23:46:54</SearchDate>
<Result>
<Summary>
<ReportSummary>
<DatablocksSummary>
<DatablockSummary>
<Name>CreditReference</Name>
<Decision/>
</DatablockSummary>
</DatablocksSummary>
</ReportSummary>
<DecisionMatrix Code="ECIGSUAT" Name="Electronic Cigarettes">
<Decision>
<Outcome Type="Primary">0</Outcome>
<Reason>Individuals DOB has not matched to active CAIS
ER or Citizen Card therefore application has been
referred
</Reason>
</Decision>
</DecisionMatrix>
</Summary>
</Result>
</Search>
现在我真的需要它在Outcome标签中的数字。我已经尝试了很多方法,但我似乎无法得到它。
非常感谢任何帮助。
提前致谢。
答案 0 :(得分:0)
为了简化SOAP的使用,您可以使用PHP内置SOAP客户端。 http://php.net/manual/en/class.soapclient.php
使用SoapClient类,您可以执行以下操作:
<?php
$soapUrl = "https://xml.proveid.experian.com/IDSearch.cfc?wdsl"
$soapClient = new SoapClient($soapUrl);
$parameters = array();
$result = $soapClient->Search($parameters);
?>
结果,您将获得本机PHP数据结构,而不是此处的纯文本XML。