I'm trying to consume a Webservice already existing and that works perfectly. After having read many tutorials and examples, I finally managed to get an answer from the server:
Server was unable to process request. Object reference not set to an instance of an object
The WS simply allows you to get and ID from an NT login (one string param, one string answer).
Here is my perl script:
#!perl -w
use strict;
use warnings;
use LWP::UserAgent;
use SOAP::Lite on_action => sub { "$_[0]$_[1]"; };
use LWP::Debug; LWP::Debug::level('+'); SOAP::Lite->import(+trace => 'all');
#use SOAP::Lite +trace => 'debug';
#sub SOAP::Transport::HTTP::Client::get_basic_credentials { return ('user' => 'pwd') };
use Data::Dumper;
my $var = SOAP::Data->new(name => 'NTLogin', value => "1234", type =>'s:string');
my $resultLogin = SOAP::Lite
-> uri('http://xxxxx')
-> proxy('http://yyyyy/zzzzz/directory.asmx')
-> on_action( sub { join '/', @_ } )
-> GetUIDFromNTLogin($var);
print "lets test it...\n\n";
print $resultLogin;
print "\nresult():\n";
print $resultLogin->result();
And here's the output:
Launching NT to UID conversion
SOAP::Data::new: ()
SOAP::Lite::new: ()
LWP::UserAgent::new: ()
SOAP::Transport::HTTP::Client::new: ()
SOAP::Lite::call: ()
SOAP::Serializer::envelope: ()
SOAP::Serializer::envelope: GetUIDFromNTLogin SOAP::Data=HASH(0x______)
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Data::new: ()
SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0x______)
SOAP::Transport::HTTP::Client::send_receive: POST http://yyyyy/zzzzz/directory.asmx
Accept: text/xml
Accept: multipart/*
Content-Length: 534
Content-Type: text/xml; charset=utf-8
SOAPAction: http://tempuri.org/GetUIDFromNTLogin
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:xsi="http://www.w
3.org/1999/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/e
ncoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="
http://www.w3.org/1999/XMLSchema" SOAP-ENV:encodingStyle="http://schemas.xmlsoap
.org/soap/encoding/"><SOAP-ENV:Body><namesp1:GetUIDFromNTLogin xmlns:namesp1="ht
tp://tempuri.org"><NTLogin xsi:type="s:string">1234</NTLogin></namesp1:
GetUIDFromNTLogin></SOAP-ENV:Body></SOAP-ENV:Envelope>
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: POST http://yyyyy/zzzzz/directory.asmx
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 441 bytes
LWP::UserAgent::request: Simple response: Internal Server Error
SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x______)
SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal Server Error
Cache-Control: private
Date: Mon, 04 Jun 2012 15:54:47 GMT
Server: Microsoft-IIS/6.0
Content-Length: 441
Content-Type: text/xml; charset=utf-8
Client-Date: Mon, 04 Jun 2012 15:54:47 GMT
Client-Peer: 10.94.61.146:80
Client-Response-Num: 1
Set-Cookie: BIGipServer_____________-http=_________________; path=/
X-AspNet-Version: 2.0.50727
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><soap:Fault><faultcode
>soap:Server</faultcode><faultstring>Server was unable to process request. ---&g
t; Object reference not set to an instance of an object.</faultstring><detail />
</soap:Fault></soap:Body></soap:Envelope>
SOAP::Deserializer::deserialize: ()
SOAP::Parser::decode: ()
SOAP::SOM::new: ()
SOAP::Lite::DESTROY: ()
SOAP::Deserializer::DESTROY: ()
SOAP::Transport::DESTROY: ()
SOAP::Transport::HTTP::Client::DESTROY: ()
SOAP::Serializer::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Data::DESTROY: ()
lets test it...
1
result():
SOAP::SOM::DESTROY: ()
SOAP::Data::DESTROY: ()
SOAP::Parser::DESTROY: ()
SOAP::Transport::DESTROY: ()
SOAP::Serializer::DESTROY: ()
SOAP::Deserializer::DESTROY: ()
SOAP::Lite::DESTROY: ()
Press any key to continue . . .
After some research I've done, I've got the impression that the error is on the WS server's side. Yet the WS seems to work perfectly, so I guess something is wrong with my Perl script but I cannot figure out what...
Any help would be very much appreciated !
Thanks,
[Update #1]
Here's the example given by the WS page:
Request
POST /zzzzz/directory.asmx HTTP/1.1
Host: yyyyy
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://xxxxx/GetUIDFromNTLogin"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUIDFromNTLogin xmlns="http://xxxxx/">
<NTLogin>string</NTLogin>
</GetUIDFromNTLogin>
</soap:Body>
</soap:Envelope>
Response
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetUIDFromNTLoginResponse xmlns="http://xxxxx/">
<GetUIDFromNTLoginResult>string</GetUIDFromNTLoginResult>
</GetUIDFromNTLoginResponse>
</soap:Body>
</soap:Envelope>
[Update #2]
Here's the output to what user1215106 suggested:
<HTML>
<HEAD><TITLE>An Error Occurred</TITLE></HEAD>
<BODY>
<H1>An Error Occurred</H1>
400 Bad Request
</BODY>
</HTML>
I found this: http://www.perlmonks.org/?node_id=719987
The guy added this line to their code:
Also, please use use strict; use warnings;
Move the shebang line at the top (#!perl)
Enable debug:
Make sure that LWP::Authen::Ntlm is installed in your system.
Currently you are getting 'HTTP/1.1 500 Internal Server Error' errors. This means that the server code dies, does not work properly. It should send you some meaningfull error message...
Regards,