如何将NTLM身份验证与Perl的SOAP :: Lite模块集成?

时间:2009-06-18 16:28:34

标签: perl soap ntlm

此Perl代码与匿名访问ASP.NET Web服务一起使用,但是当启用集成安全性时,该服务将返回401错误。我想我需要将NTLM模块与SOAP :: Lite一起使用,但目前尚不清楚如何这样做。如何整合这些组件?

use SOAP::Lite;
use strict;

my $proxy = "http://localhost:28606/WebService.asmx";

my $method_name = "HelloWorld";
my $uri = "http://tempuri.org/";
my $methodAction = $uri . $method_name;

my $soap = SOAP::Lite
    ->uri( $uri )
    ->proxy( $proxy )
    ->on_action(sub{ $methodAction; });

my $method = SOAP::Data->name($method_name)->attr({xmlns=>$uri});
my $result = $soap->call($method);

print $result->result();

2 个答案:

答案 0 :(得分:2)

如果你这样做,你可以让SOAP :: Lite打印一些调试输出:

use SOAP::Lite +trace;

而不是

use SOAP::Lite;

编辑:

好的,我想我现在明白了。打开集成安全功能使IIS需要NTLM身份验证。有一个thread over at perlmonks.org似乎揭示了答案。

答案 1 :(得分:1)

我有点晚了,但我遇到了同样的问题。试试这个:

use LWP::UserAgent;
use LWP::Debug;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };
import SOAP::Data 'name', 'value';
our $sp_endpoint = 'http://sp.example.com/sites/mysite/_vti_bin/lists.asmx';
our $sp_domain = 'sp.example.com:80';
our $sp_username = 'DOMAIN\username';
our $sp_password = 'xyz';

if ($debug) {
    LWP::Debug::level('+');
    SOAP::Lite->import(+trace => 'all');
}

my @ua_args = (keep_alive => 1);
my @credentials = ($sp_domain, "", $sp_usernam, $sp_password);
my $schema_ua = LWP::UserAgent->new(@ua_args);
$schema_ua->credentials(@credentials);
$soap = SOAP::Lite->proxy($sp_endpoint, @ua_args, credentials => \@credentials);
$soap->schema->useragent($schema_ua);
$soap->uri("http://schemas.microsoft.com/sharepoint/soap/");