最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Soap Login with PHP - Stack Overflow

programmeradmin1浏览0评论

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论