Hi,
I am using the following code to send and XML document ( output.xml ) to a
remote server:

use strict;
use LWP::Debug qw(+);
use LWP::UserAgent;
use IO;

my $resp;
$resp = 'response.xml';
my $FILEH;
open (FILEH, <output.xml>) or die "Can't open file output.xml!\n";

my $ua = LWP::UserAgent->new;

#another version that i've tried...
#my $h = new HTTP::Headers Date=> '2001-05-18';
#my $req =
HTTP::Request->new('POST','http://195.252.142.171:8008',$h,$FILEH);

my $req = HTTP::Request->new(POST => 'http://195.252.142.171:8008');

#$req->content_type('text/xml'); 
$req->content($FILEH);

my $res = $ua->request($req,$resp); <--------------------here I've also
tried plain request($req) but the result is the same
if ( $res->is_success) {
   print "OK!\n";
   #print $res->as_string;
} else {
   print "Failed: ", $res->status_line, "\n";
}

And that's what I get:

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::simple_request: POST http://195.252.142.171:8008/
LWP::UserAgent::_need_proxy: (http://195.252.142.171:8008/)
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: POST / HTTP/1.0
Host: 195.252.142.171:8008
User-Agent: libwww-perl/5.21

LWP::Protocol::http::request: reading response
LWP::UserAgent::request: Simple result: Internal Server Error
Failed: 500 read timeout

#######
Could anyone please help me? The problem is that I am not too sure whether
my request is correct in the first place.
In the manuals, $content is described as 'an arbitrary amount of data'.. Is
my filehandle properly interpreted? I've tried
using only the name of the file, but obviously it didn't work, being
interpreted as a 10 chars long string...

Thanks in advance,
Ela

Reply via email to