4

此 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();
4

2 回答 2

2

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

use SOAP::Lite +trace;

代替

use SOAP::Lite;

编辑:

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

于 2009-06-18T18:58:25.507 回答
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/");
于 2009-12-27T11:05:05.133 回答