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

发布于 2024-07-24 12:02:22 字数 595 浏览 6 评论 0原文

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

This Perl code works with Anonymous access to an ASP.NET web service, but when integrated security is turned on, the service returns 401 errors. I think I need to use the NTLM module in conjunction with SOAP::Lite, but it's not clear how to do so. How can these components be integrated?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬色的秋千 2024-07-31 12:02:22

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

use SOAP::Lite +trace;

而不是

use SOAP::Lite;

编辑:

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

You can get SOAP::Lite to print some debugging output if you do:

use SOAP::Lite +trace;

instead of

use SOAP::Lite;

EDIT:

OK, I think I get it now. Turning on the integrated security feature makes IIS require NTLM authentication. There's a thread over at perlmonks.org that seems to reveal the answer.

岁月苍老的讽刺 2024-07-31 12:02:22

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

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/");

I'm a bit late, but I just faced the same problem. Try this:

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/");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文