【问题标题】:NuSoap PHP webservice with soap headers [closed]带有肥皂头的 NuSoap PHP Web 服务 [关闭]
【发布时间】:2011-10-09 18:59:42
【问题描述】:

我想知道如何使用 NuSoap 库在肥皂网络服务服务器中实现肥皂头身份验证。

我看过很多关于 NuSoap 客户端的例子,但想在服务器中实现它。

【问题讨论】:

    标签: php web-services soap nusoap


    【解决方案1】:
        $client->setHeaders('<wsse:Security S:mustUnderstand="1">
                <wsu:Timestamp xmlns:ns15="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="_1">
                    <wsu:Created>createdDate</wsu:Created>
                    <wsu:Expires>expireDate</wsu:Expires>
                </wsu:Timestamp>
                <wsse:UsernameToken xmlns:ns15="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity" xmlns:ns14="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512" xmlns:ns13="http://www.w3.org/2003/05/soap-envelope" wsu:Id="uuid_25007e25-6a0a-4a0c-9c3e-0d332f262cdc">
                    <wsse:Username>username</wsse:Username>
                    <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password>
                </wsse:UsernameToken>
            </wsse:Security>');
    

    【讨论】:

      【解决方案2】:

      soapserver 对象将soap 标头作为'requestHeader' 属性下的关联数组保存,因此如果您能找到一种从您的函数中获取服务器实例的方法,您将能够获取soapHeader。

      <?php
      require_once './nusoap/nusoap.php';
      
      //Declare the server as a global, for brevity
      global $server;
      
      //Instantiate, configure and run as usual
      $server = new nusoap_server();
      $server->configureWSDL("namespace...", "...");
      $server->register("myHandler");
      $server->service(isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '');
      
      //My handling function:
      function myHandler() {
          //Get your server instance:
          global $server;
      
          //Abra Kadabra alakazam! your soap header :D
          var_dump($server->requestHeader);
      }
      

      这样做显然有更好的编码实践,但你明白了。还有 whatchout 用于 requestHeaders 属性,因为它包含 HTTP 标头而不是 SOAP 标头,请记住:没有尾随 's' 的 requestHeader 是你的人。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-12
        • 1970-01-01
        • 2012-08-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多