我正在开展一个项目,该项目需要使用他们的 API 向 National Student ClearingHouse 验证注册成员。我一直在互联网上到处寻找一些描述如何查询方法或示例的片段,但到目前为止还没有运气。文档在 php 中实现也非常有限,而且我从未在 SOAP 上工作过,所以这对我来说更加复杂。
不知何故,我设法从这里开始是代码:
$soap_url = 'https://xml.studentclearinghouse.org/ws/wsdl/HRXMLVerify.wsdl';
$client = new SoapClient($soap_url, array(
'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
'SOAPENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
'xsi' => 'http://www.w3.org/2001/XMLSchemainstance',
'xsd' => 'http://www.w3.org/2001/XMLSchema'
));
$data = array(
'BackgroundCheck' => array(
'account' => 'xxxx',
'userid' => 'xxxxx',
'password' => 'xxxxx'
),
'BackgroundSearchPackage' => array()
);
echo '<pre>';
print_r($client->__soapCall('verifyHRXML', $data));
哪个输出:
SoapFault Object
(
[message:protected] => SOAP-ERROR: Encoding: object has no 'BackgroundSearchPackage' property
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => /Applications/MAMP/htdocs/nch/index.php
[line:protected] => 39
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => /Applications/MAMP/htdocs/nch/index.php
[line] => 39
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => verifyHRXML
[1] => Array
(
[BackgroundCheck] => Array
(
[account] => xxxxxx
[userid] => xxxxx
[password] => xxxxxx
)
[BackgroundSearchPackage] => Array
(
)
)
)
)
)
[previous:Exception:private] =>
[faultstring] => SOAP-ERROR: Encoding: object has no 'BackgroundSearchPackage' property
[faultcode] => Client
[faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)
非常糟糕地卡住了这一点。