PHP soap请求基本身份验证的SOAP服务器

时间:2013-01-29 20:06:26

标签: php authentication soap lighttpd

我需要一些帮助,创建一个本机php soap客户端,它请求一个基本的auth安全lighttpd soap服务器。我的光auth.conf是

server.modules              += ( "mod_auth" )
auth.debug                   = 2
auth.backend                 = "plain"
auth.backend.plain.userfile  = "/etc/lighttpd/lighttpd.user"

auth.require                 = ( "" => 
                           ( 
          "method"  => "basic",
          "realm"   => "secured area",
          "require" => "user=maintainer"
        )
                        )

我的soapserver代码是

function test(){
return "ok";
}

$server = new SoapServer(null, 
array( 
     'uri'=>"https://0.0.0.0/test-uri",
     'encoding'=>'UTF-8', 
     'soap_version'=>SOAP_1_2
     ) 
 );

$server->addFunction("test");
$server->handle();

我的客户端代码是

    $soap = new SoapClient(null, 
     array( 
           'connection_timeout' => 5,
           'location' => "https://10.18.10.134/index.php",
           'style' => SOAP_RPC,
           'use' => SOAP_ENCODED,
           'uri' => "https://test-uri",
           "soap_version" => SOAP_1_2,
           'login ' => "maintainer",
           'password ' => "xxxxxxx",
           "trace" => 1
          ) 
     );

try{
    $result= $soap->test();
}
catch (Exception $e) {
    echo 'Exception abgefangen: ',  $e->getMessage(), "\n";
}
echo $soap->__getLastResponse()."\n";

echo $result."\n";

但与网络上的教程相反,我的唯一回应是

DTD are not supported by SOAP
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>401 - Unauthorized</title>
 </head>
 <body>
  <h1>401 - Unauthorized</h1>
 </body>
</html>

我无法相信没有办法让这项工作成功。我无法看到的错误是什么?

经过一些研究后,在我看来,没有办法让配置工作。问题是fgci接口没有通过登录参数。我发现一些重写黑客作为一种解决方法,但没有解决问题的真正解决方案。因此我决定使用证书进行编码和验证。

0 个答案:

没有答案