使用带有NTLM身份验证的Perl中的.NET Web服务

使用带有NTLM身份验证的Perl中的.NET Web服务,.net,perl,soap,ntlm,strawberry-perl,.net,Perl,Soap,Ntlm,Strawberry Perl,我试图从Perl脚本调用.NETSOAPWeb服务,如下所示 #!/usr/bin/perl -w use strict; use SOAP::Lite 'trace', 'debug'; use Authen::NTLM; use Data::Dumper; my $user = '\\username'; my $pass = 'password'; my $host = 'host.example.com:80'; # enable NTLMv2 in Authen::NTLM ntl

我试图从Perl脚本调用.NETSOAPWeb服务,如下所示

#!/usr/bin/perl -w
use strict;
use SOAP::Lite 'trace', 'debug';
use Authen::NTLM;
use Data::Dumper;

my $user = '\\username';
my $pass = 'password';
my $host = 'host.example.com:80';

# enable NTLMv2 in Authen::NTLM
ntlmv2(1);


my $soap = SOAP::Lite
    -> uri('http://application.dept.example.com')
    -> proxy('http://host.example.com/app/services/request.asmx', keep_alive => 1, credentials => [$host, '', $user, $pass])
    -> on_action(sub { join '/', 'http://application.dept.example.com', $_[1] })# needed for .NET
    -> readable(1)
    ;

my $som = $soap->GetData(
    SOAP::Data->name(ID => 1234)
);
die $som->faultstring() if defined $som->fault();
my @result = $som->dataof('//GetResponse/GetResult');

foreach my $data (@result) {
    my $item = $data->attr;
    print Dumper($item);
}
然而,当我执行这个脚本时,我得到了这个输出。你会注意到我没有得到任何结果

SOAP::Transport::HTTP::Client::send_receive: POST http://host.example.com/app/services/request.asmx HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 542
Content-Type: text/xml; charset=utf-8
SOAPAction: http://application.dept.example.com/GetData

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetData xmlns="http://application.dept.example.com">
      <ID xsi:type="xsd:int">1234</materialID>
    </GetData>
  </soap:Body>
</soap:Envelope>
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Sat, 25 Aug 2012 14:43:05 GMT
Server: Microsoft-IIS/7.5
Content-Length: 367
Content-Type: text/xml; charset=utf-8
Client-Date: Sat, 25 Aug 2012 14:43:03 GMT
Client-Peer: 165.216.6.189:80
Client-Response-Num: 3
Persistent-Auth: true
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetResponse xmlns="http://application.dept.example.com/">
<GetResult />
</GetResponse>
</soap:Body>
</soap:Envelope>

$VAR1 = {};
SOAP::Transport::HTTP::Client::send\u receive:POSThttp://host.example.com/app/services/request.asmx HTTP/1.1
接受:text/xml
接受:多部分/*
接受:应用程序/soap
内容长度:542
内容类型:text/xml;字符集=utf-8
SOAPAction:http://application.dept.example.com/GetData
1234
SOAP::Transport::HTTP::Client::发送\接收:HTTP/1.1 200确定
缓存控制:专用,最大年龄=0
日期:2012年8月25日星期六14:43:05 GMT
服务器:Microsoft IIS/7.5
内容长度:367
内容类型:text/xml;字符集=utf-8
客户日期:2012年8月25日星期六14:43:03 GMT
客户端对等机:165.216.6.189:80
客户端响应数:3
持久身份验证:true
X-AspNet-Version:4.0.30319
X-Powered-By:ASP.NET
$VAR1={};

我已经确认这个服务确实有效——所以问题出在我的脚本上。我对使用web服务非常陌生,因此希望您提供任何指导。

如果您查看返回的数据,则
//GetResponse/GetResult
引用的节点是一个空元素

<GetResponse xmlns="http://application.dept.example.com/">
  <GetResult />
</GetResponse>

因此,您的程序正在正确地查找元素,并且没有显示任何内容