2009-06-18 72 views
4

此Perl代碼與匿名訪問ASP.NET Web服務一起工作,但啓用集成安全性後,該服務將返回401個錯誤。我認爲我需要將NTLM模塊與SOAP :: Lite結合使用,但目前尚不清楚如何實現。這些組件如何集成?如何將Perl的SOAP :: Lite模塊與NTLM身份驗證集成?

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

究竟是什麼「集成安全性」? – innaM 2009-06-18 18:55:08

回答

2

你可以得到SOAP ::精簡版打印一些調試輸出,如果你這樣做:

use SOAP::Lite +trace; 

,而不是

use SOAP::Lite; 

編輯:

OK,我想我現在得到它。打開集成安全功能使IIS需要NTLM身份驗證。有一個thread over at perlmonks.org似乎揭示了答案。

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