I have check and read a lot of questions and answers about how to make a soap login, but I don't get work my code.
I have try with php SoapClass
$context = stream_context_create([
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
],
]);
$options = [
'stream_context' => $context,
'trace' => 1, // Para depuración
'exceptions' => true, // Lanza excepciones en caso de error
'cache_wsdl' => WSDL_CACHE_NONE, // Desactiva el cache para evitar problemas con versiones desactualizadas
'connection_timeout' => 30, // Timeout para la conexión
];
// $this->serviceUrl => .asmx?WSDL
$soapClient = new SoapClient($this->serviceUrl, $options);
$params = [
'sSeguridad' => 'XXXXX',//$this->sSeguridad,
'NIF' => 'XXXXX', // $nif,
'Clave' => 'XXXXX',
];
$result = $soapClient->__soapCall(
'ComprobarCredencialesPorNIFyClave',
$params
);
I get this error:
SoapFault: Internal Server Error in SoapClient->__doRequest() (line 108 of modules/custom/aea_login/src/AeaSoapClient.php).
If I try with xlm with this code:
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:xsi=";
xmlns:xsd=";
xmlns:soap="/">
<soapenv:Header/>
<soapenv:Body>
<ComprobarCredencialesPorNIFyClave xmlns=".asmx">
<sSeguridad>$sSeguridad</sSeguridad>
<NIF>$NIF</NIF>
<Clave>$Clave</Clave>
</ComprobarCredencialesPorNIFyClave>
</soapenv:Body>
</soapenv:Envelope>
XML;
$result = $soapClient->__doRequest(
$xml,
$service_url,
'ComprobarCredencialesPorNIFyClave',
SOAP_1_1,
);
I don't get any error but a null return.
If I try the URL and the params (sSeguridad, NIF, Clave) with SopUI software it works perfect, so it's not the params or the url