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

Dear All, I have written some perl that retrieves a web page from a web server using LWP::UserAgent. The code works fine from the command line but when I run the code within Interwoven TeamSite Templating it produces the following error :-
500 (Internal Server Error) Can't connect to 128.31.33.22:80 (Cannot determine protocol) Client-Date: Wed, 12 Mar 2003 14:16:15 GMT
Basically TeamSite Templating allows you to run perl code inside a presentation template (merge content with presentation). This is all running on Windows 2000.
The code is :-
use LWP::UserAgent; use DBI; #Step 1 : Move dcr to correct location #Step 2 : Generate acuate report - SOAP call #Step 3 : Call JSP $page = 'http://128.31.33.22/maintenance/adrian/reportlet/Green_1b +/repServerRed.jsp?username=adrianh'; $ua = new LWP::UserAgent; my $req = new HTTP::Request ('GET' => $page); $req->content_type('application/x-www-form-urlencoded'); my $res = $ua->request($req); my $html = $res->as_string;

Replies are listed 'Best First'.
Re: Cannot determine protocol
by PodMaster (Abbot) on Mar 12, 2003 at 15:16 UTC
    I cannot offer an answer (as that's a little bizzare), but you should do more debugging -- see LWP::Debug, LWP::DebugFile


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: Cannot determine protocol
by pg (Canon) on Mar 12, 2003 at 15:43 UTC
    Found something for you, hope this link helps.
Re: Cannot determine protocol
by grinder (Bishop) on Mar 12, 2003 at 16:12 UTC

    Well your requested URL looks okay to me, but how do you know you aren't hitting a redirect, and it's some subsequent URL that's causing you grief?

    A simple check to see whether this is the case would look something like (tested):

    #! /usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Request; my $ua = LWP::UserAgent->new; my $res = $ua->simple_request( HTTP::Request->new('GET', shift )); print $res->status_line, "\n";

    If you get a 300, 301 or 302 you're being redirected, so you'll have to look farther afield. If, as it appears in your comments, you are using SOAP, why don't you take a look at the SOAP hierarchy on CPAN?


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
Re: Cannot determine protocol
by lablett (Initiate) on Mar 12, 2003 at 16:55 UTC
    Me Again, Is there a way to test the network settings in the perl script, as I think there is a network issue because I cannot connect to a database either!