嗨,我必须建立一个肥皂客户端来发出以下请求: https://api.edu.gov.pt/services/e360/listStudentCodes?wsdl 这是我的代码:
$Username="********";
$PAssword="********";
$anolectivo=2017;
$CodEscola=123456;
$Codes="https://api.edu.gov.pt/services/e360/listStudentCodes?wsdl";
$options = array(
'login' => $Username,
'password' => $password,
'exceptions' => false,
'trace' => 1
,'stream_context' => stream_context_create(array('ssl'=>array('verify_peer'=>false,'verify_peer_name'=>false, 'allow_self_signed' => true)))
);
try{
$client = new SoapClient($Codes,$options);
$result = $client->__soapCall("ListarCodigosAlunos",array('AnoLetivo' => $anolectivo,'CodigoAgrupamento' => $CodEscola,'CodigoEscola' => $CodEscola),$options);
if (is_soap_fault($result)) {
trigger_error("Error SOAP: (faultcode: {$result->faultcode}, faultstring: {$result->faultstring})", E_USER_ERROR);
}else print_r($result);
} catch (Exception $e) {
echo "<h2>Exception Error!</h2>";
echo $e->getMessage();
}
但是我得到的只是:
致命错误:SOAP错误:解析WSDL:第34行E:\ xampp \ htdocs \ SOAP \ test.php中未知的必需WSDL扩展'http://www.w3.org/2006/05/addressing/wsdl'
我设法降到了
SoapFault Object
(
[message:protected] => Wrong Version
[string:Exception:private] =>
[code:protected] => 0
[file:protected] => E:\xampp\htdocs\SOAP\e360T2.php
[line:protected] => 46
[trace:Exception:private] => Array
(
[0] => Array
(
[file] => E:\xampp\htdocs\SOAP\e360T2.php
[line] => 46
[function] => __soapCall
[class] => SoapClient
[type] => ->
[args] => Array
(
[0] => ListarCodigosAlunos
[1] => Array
(
[AnoLetivo] => 2018
[CodigoAgrupamento] => 400324
[CodigoEscola] => 400324
)
答案 0 :(得分:0)
您有两个选择:
自己下载WSDL文件,对其进行编辑以将wsdl:required="true"
更改为wsdl:required="false"
,然后将SOAP客户端配置为使用本地WSDL。
或者使用类似于以下库之一的外部库来了解WSDL扩展: