Perl SOAP::Lite服务-使用NTLM和Navision 2009 SP1进行身份验证

Perl SOAP::Lite服务-使用NTLM和Navision 2009 SP1进行身份验证,perl,web-services,soap,navision,soaplite,Perl,Web Services,Soap,Navision,Soaplite,我正在尝试连接到Navision 2009 SP1公开的Web服务,它需要NTLM身份验证 authentication对service()调用有效——这意味着我得到了返回的存根!但是,只要我尝试调用一个函数,身份验证就消失了 我尝试过再次为$service设置凭据(该服务缺少keep_alive),也尝试过使用PATCH_HTTP_KEEPALIVE常量,但两者都没有帮助 $SOAP::Constants::PATCH_HTTP_KEEPALIVE = 1; # does this even

我正在尝试连接到Navision 2009 SP1公开的Web服务,它需要NTLM身份验证

authentication对service()调用有效——这意味着我得到了返回的存根!但是,只要我尝试调用一个函数,身份验证就消失了

我尝试过再次为$service设置凭据(该服务缺少keep_alive),也尝试过使用PATCH_HTTP_KEEPALIVE常量,但两者都没有帮助

$SOAP::Constants::PATCH_HTTP_KEEPALIVE = 1; # does this even do anything?

my $ua = LWP::UserAgent->new(keep_alive => 1);
$ua->credentials($host, '', $domain_user, $password);

my $client = SOAP::Lite->new();
$client->schema->useragent($ua);

# this works!
my $service = $client->service($service_url)->proxy($service_url);

# this is just a test - how can I set keep_alive again?
$service->{_transport}->{_proxy}->credentials($host, '', $domain_user, $password);

# this returns 401 unauthorized
$service->Read('R1446781');
这是我得到的全部答复:

SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x224adf8)
SOAP::Transport::HTTP::Client::send_receive: POST http://somedomain.org:7047/DynamicsNAV/WS/Company%20Name/Page/InvHeader HTTP/1.1
Accept: text/xml
Accept: multipart/*
Accept: application/soap
Content-Length: 485
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:microsoft-dynamics-schemas/page/invheader:Read"

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:microsoft-dynamics-schemas/page/invheader" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soap:Body><tns:Read><No xsi:type="xsd:string">R1446781</No></tns:Read></soap:Body></soap:Envelope>
The keep_alive option must be enabled for NTLM authentication to work.  NTLM authentication aborted.
SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x22511b8)
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 401 Unauthorized
Date: Fri, 06 Feb 2015 09:42:22 GMT
Server: Microsoft-HTTPAPI/2.0
WWW-Authenticate: NTLM
Content-Length: 0
Client-Date: Fri, 06 Feb 2015 09:42:22 GMT
Client-Peer: somedomain.org:7047
Client-Response-Num: 1

401 Unauthorized at script/test_webservice.pl line 36.
SOAP::Transport::HTTP::Client::send\u receive:HTTP::Request=HASH(0x224adf8)
SOAP::Transport::HTTP::Client::发送\接收:POSThttp://somedomain.org:7047/DynamicsNAV/WS/Company%20Name/Page/InvHeader HTTP/1.1
接受:text/xml
接受:多部分/*
接受:应用程序/soap
内容长度:485
内容类型:text/xml;字符集=utf-8
SOAPAction:“urn:microsoft dynamics架构/page/invheader:Read”
R1446781
必须启用keep_alive选项,NTLM身份验证才能工作。NTLM身份验证已中止。
SOAP::Transport::HTTP::Client::发送\接收:HTTP::响应=哈希(0x2251B8)
SOAP::Transport::HTTP::Client::发送\接收:HTTP/1.1 401未经授权
日期:2015年2月6日星期五09:42:22 GMT
服务器:Microsoft HTTPAPI/2.0
WWW:NTLM
内容长度:0
客户日期:2015年2月6日星期五09:42:22 GMT
客户端:somedomain.org:7047
客户端响应编号:1
401脚本/test_webservice.pl第36行未经授权。
如何使用已用于service()调用的相同身份验证对$service函数进行身份验证?

解决了这个问题:

$service->transport->proxy->conn\u cache($ua->conn\u cache)

它必须使用相同的连接缓存,然后才能工作