php soapclient 请求响应
php soapclient request response
您好,我必须构建一个 soap 客户端来向:
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();
}
但我得到的是:
Fatal error: SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://www.w3.org/2006/05/addressing/wsdl' in E:\xampp\htdocs\SOAP\test.php on line 34
我设法下降到
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
)
您有两个选择:
自行下载 WSDL 文件,编辑它以将 wsdl:required="true"
更改为 wsdl:required="false"
,然后配置您的 SOAP 客户端以使用本地 WSDL。
或者使用理解 WSDL 扩展的外部库,例如其中之一:
您好,我必须构建一个 soap 客户端来向: 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();
}
但我得到的是:
Fatal error: SOAP-ERROR: Parsing WSDL: Unknown required WSDL extension 'http://www.w3.org/2006/05/addressing/wsdl' in E:\xampp\htdocs\SOAP\test.php on line 34
我设法下降到
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
)
您有两个选择:
自行下载 WSDL 文件,编辑它以将 wsdl:required="true"
更改为 wsdl:required="false"
,然后配置您的 SOAP 客户端以使用本地 WSDL。
或者使用理解 WSDL 扩展的外部库,例如其中之一: