jgfcoimbra has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to get access to a sharepoint webpage from Unix. This is the code that I am using to do that, without my username and passwd, everything is as it shoud be.
#!/bin/perl use LWP::UserAgent; use LWP::Debug; use Data::Dumper; use SOAP::Lite on_action => sub { "$_[0]$_[1]"; }; import SOAP::Data 'name', 'value'; our $sp_endpoint = 'http://in.nokia.com/sites/s40configmanag/_vti_bin/ +copy.asmx'; our $sp_domain = 'NOE'; our $sp_username = 'USERNAME'; our $sp_password = 'PASSWD'; $debug = 1; if ($debug) { LWP::Debug::level('+'); SOAP::Lite->import(+trace => 'all'); } my @ua_args = (keep_alive => 1); my @credentials = ($sp_domain, "", $sp_username, $sp_password); my $schema_ua = LWP::UserAgent->new(@ua_args); $schema_ua->credentials(@credentials); $soap = SOAP::Lite->proxy($sp_endpoint, @ua_args, credentials => \@cre +dentials); $soap->schema->useragent($schema_ua); $soap->uri("http://schemas.microsoft.com/sharepoint/soap/"); $lists = $soap->GetListCollection(); quit(1, $lists->faultstring()) if defined $lists->fault(); sub lists_getid { my $title = shift; my @result = $lists->dataof('//GetListCollectionResult/Lists/List'); foreach my $data (@result) { my $attr = $data->attr; return $attr->{ID} if ($attr->{Title} eq $title); } return undef; } sub lists_getitems { my $listid = shift; my $in_listName = name('listName' => $listid); my $in_viewName = name('viewName' => ''); my $in_rowLimit = name('rowLimit' => 99999); my $call = $soap->GetListItems($in_listName, $in_viewName, $in_rowLi +mit); quit(1, $call->faultstring()) if defined $call->fault(); return $call->dataof('//GetListItemsResult/listitems/data/row'); } my $list_id = lists_getid('TB104 UI config report'); print "List ID is: $list_id\n"; my @items = lists_getitems($list_id); foreach my $data (@items) { my $attr = $data->attr; print Dumper($attr); }
This is my output:
joacoimb@farem001 ui_config_tools $ perl ./webdav_interface2.pl LWP::UserAgent::new: () SOAP::Lite::new: () LWP::UserAgent::new: () SOAP::Transport::HTTP::Client::new: () SOAP::Deserializer::new: () SOAP::Parser::new: () LWP::UserAgent::new: () SOAP::Schema::new: () SOAP::Lite::call: () SOAP::Serializer::envelope: () SOAP::Serializer::envelope: GetListCollection SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Data::new: () SOAP::Transport::HTTP::Client::send_receive: HTTP::Request=HASH(0xb4f2 +90) SOAP::Transport::HTTP::Client::send_receive: POST http://in.nokia.com/ +sites/s40configmanag/_vti_bin/copy.asmx HTTP/1.1 Accept: text/xml Accept: multipart/* Accept: application/soap Content-Length: 457 Content-Type: text/xml; charset=utf-8 SOAPAction: http://schemas.microsoft.com/sharepoint/soap/GetListCollec +tion <?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsi="http:/ +/www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xm +lsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema +" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmln +s:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetLis +tCollection xmlns="http://schemas.microsoft.com/sharepoint/soap/" xsi +:nil="true" /></soap:Body></soap:Envelope> LWP::UserAgent::request: () LWP::UserAgent::send_request: POST http://in.nokia.com/sites/s40config +manag/_vti_bin/copy.asmx LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::http::request: Keep the http connection to in.nokia.com +:80 LWP::UserAgent::request: Simple response: Found LWP::UserAgent::request: () LWP::UserAgent::send_request: GET https://in.nokia.com/sites/s40config +manag/_vti_bin/copy.asmx LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::UserAgent::request: Simple response: Internal Server Error SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0xe5d +b90) SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to in.n +okia.com:443 (Bad service '8080/') Content-Type: text/plain Client-Date: Mon, 24 Jan 2011 11:07:33 GMT Client-Warning: Internal response 500 Can't connect to in.nokia.com:443 (Bad service '8080/') SOAP::Deserializer::deserialize: () SOAP::Parser::decode: () 500 Can't connect to in.nokia.com:443 (Bad service '8080/') at ./webda +v_interface2.pl line 37 SOAP::Parser::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Data::DESTROY: () SOAP::Transport::HTTP::Client::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Schema::DESTROY: () SOAP::Serializer::DESTROY: () SOAP::Data::DESTROY: () SOAP::Parser::DESTROY: () SOAP::Transport::DESTROY: () SOAP::Serializer::DESTROY: () SOAP::Deserializer::DESTROY: () SOAP::Lite::DESTROY: () SOAP::Lite::DESTROY: () joacoimb@farem001 ui_config_tools $
I am concerned about these 3 lines here:
LWP::UserAgent::request: Simple response: Internal Server Error SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0xe5d +b90) SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to in.n +okia.com:443 (Bad service '8080/')
Any ideas why am I getting these errors? many thanks, Joao

Replies are listed 'Best First'.
Re: SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to
by Anonymous Monk on Jan 24, 2011 at 11:34 UTC
    Are you using a proxy, one whose URI ends in '8080/'? Try getting rid of the trailing slash
      I am using exactly the code that is presented here. I don't know where the :8080 is comming from. BR, Joao
Re: SOAP::Transport::HTTP::Client::send_receive: 500 Can't connect to
by Anonymous Monk on Jan 25, 2011 at 07:46 UTC
      Thanks , I have removed that, but that is not the cause of my issue. Any ideas?

        From somewhere, your program gets the idea that 8080 is a (https?) proxy somewhere along the way. Check that %ENV does not contain the string 8080 anywhere. Maybe it is $ENV{HTTP_PROXY} or $ENV{SSL_PROXY} or $ENV{HTTPS_PROXY} or something like that. It's best to remove (or at least, closely inspect) these environment variables before the Perl script actually launches, so that the SSL libraries have no chance of separately picking them up before you manipulate them from Perl.