2
votes

Hi I have to build a soap client to make request to: https://api.edu.gov.pt/services/e360/listStudentCodes?wsdl Here is my Code:

$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(); 
} 

but All i get is:

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


i manage to go down to

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
                                )
1
PS: it is impossible to change the soap serverbrincas
'verify_peer'=>false,'verify_peer_name'=>false, 'allow_self_signed' => true This is very bad practice. Configure your server properly.miken32

1 Answers

0
votes

You have two options:

Download the WSDL file yourself, edit it to change wsdl:required="true" to wsdl:required="false" and then configure your SOAP client to use the local WSDL.

Or use an external library like one of these that understands the WSDL extensions:

https://github.com/robrichards/wse-php

https://github.com/coopTilleuls/wse-php