2012-08-25 2 views
0

다음과 같이 Perl 스크립트에서 .NET SOAP 웹 서비스를 호출하려고합니다.NTLM 인증을 사용하여 Perl로 .NET 웹 서비스 사용하기

#!/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 = {}; 

이 서비스가 실제로 작동한다는 것을 확인했습니다. 문제는 제 스크립트 때문입니다. 나는 웹 서비스를 사용하는 것에있어 매우 익숙하다. 그래서 어떤 지침도 인정 될 것이다.

답변

0

당신이 반환 된 데이터를 보면, //GetResponse/GetResult에 의해 참조 노드가 빈 요소

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

그래서 당신의 프로그램이 제대로 요소를 발견하고 아무것도

표시되지에게 있습니다
관련 문제