1

我是 SharePoint 开发人员,试图让 Perl 模块与 Subversion 一起使用,但我认为我的语法有问题。我只需要获取用户名和密码,将其传递到 Web 服务,获取真/假并根据该信息进行身份验证。下面是 Perl 中模块的代码:

package Apache2::AuthGetUser; #authenticates users based on bool value from a asmx webservice
use SOAP::Lite;
use Data::Dumper;
use strict;
use warnings;
use Apache2::Access();
use Apache2::RequestRec();
use Apache2::Const ':common';

sub handler {
    my $r = shift;
    my $username = $r->user;
    my ($status, $password) = $r->get_basic_auth_pw;
    return $status unless $status == Apache2::Const::OK;

    my $endpoint = "http://localhost:2010/CIM.FBAAuthentication/12/template/layouts/wsFBAAuthentication.asmx"; #endpoint
    my $namespace = "http://tempuri.org/"; #namespace
    my $wsfunction = "AuthenticateUser"; #webservice function
    my $webservice = SOAP::Lite
        ->uri($namespace)
        ->on_action(sub { join '/', $namespace, $_[1] })
        ->proxy($endpoint);

    #my $method = SOAP::Data->name($wsfunction)
    my $method = SOAP::Data->name($wsfunction)
      ->attr({xmlns => $namespace});


    my @params = (SOAP::Data->name('UserName')->value($username)->type(''), SOAP::Data->name('Password')->value($password)->type(''));

    my $result = $webservice->call($method=>@params)->result;
    if($result ne "true"){
          $r->note_basic_auth_failure;
          #$r->log_reason($result);
          return AUTH_REQUIRED;
    }

    return Apache2::Const::OK;

}
1;

如果有人有任何建议,请告诉我。我在 Apache Config 文件中收到类似的错误:Can't call method "value" on an undefined value at C:/usr/site/lib/Apache2/AuthGetUser.pm 第 30 行。感谢您所做的一切。如果我得到这个工作,我将有一篇博客文章即将发布。

4

1 回答 1

1

尝试打破这条线

 my @params = (SOAP::Data->name('UserName')->value($username)->type(''), SOAP::Data->name('Password')->value($password)->type(''));

例如确实

 my $userParam = SOAP::Data->name('UserName')->value($username)->type('xsd:string');

工作?怎么样:

 my $userParam = SOAP::Data->new(name => 'UserName', value => $username, type => 'xsd:string');

 my @params = ($userParam, $pwdParam);

您在其中定义 $pwdParam 类似。

于 2010-01-11T16:47:36.750 回答