首页 > 解决方案 > ns1:FailedAuthenticationThe security token could not be authenticated or authorized

问题描述

这是我用于身份验证的 xml 代码:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:esf="esf">
<soapenv:Header>
  <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

        <wsse:UsernameToken  xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

        <wsse:Username>my_username</wsse:Username>

        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">my_password</wsse:Password>

        </wsse:UsernameToken>
        </wsse:Security>
     </soapenv:Header>
  <soapenv:Body>
  <esf:createSessionRequest>
     <tin>my_bin</tin>
     <x509Certificate>my_cert</x509Certificate>
    </esf:createSessionRequest>
  </soapenv:Body>
 </soapenv:Envelope>

有连接到网站

   try{ $CreateSession = $SessionService>__doRequest 
   ($Create_session_xml, 'https://esf.gov.kz:8443/esfweb/ws/SessionService wsdl', '', SOAP_1_2);

   echo $CreateSession;// here I get error: FailedAuthenticationThe security token could not be authenticated or authorized

  } catch(SoapFault $e){
  echo "Error: ".$e->getMessage().PHP_EOL;
  }

我在这个网站上注册了,查了一下。所以我的数据没有问题。

有什么想法吗?请帮忙,我通过互联网搜索,没有结果。

编辑:从评论中获取的soap客户端的初始化。

$SessionService = new SoapClient(NULL, [ 
    "location" => "esf.gov.kz:8443/esf-web/ws/SessionService", 
    "uri" => "esf-test.kgd.gov.kz:9443", 
    "style" => SOAP_DOCUMENT, 
    "use" => SOAP_LITERAL, 
    "stream_context" => $context 
]);

标签: phpxmlsoap

解决方案


推荐阅读