Burlap: Perl Example
From Resin 3.0
- !/usr/bin/perl -w
use strict; use LWP::UserAgent; use HTTP::Cookies;
- use LWP::Debug qw(+);
use XML::Simple;
my( $DEBUG ) = 1;
my( $cookie_jar ) = HTTP::Cookies->new( autosave => 1, ignore_discard => 1 );
my( $ua ) = LWP::UserAgent->new(); my( $req ) = new HTTP::Request( 'POST', "http://10.20.30.40:8080/context/servlet/test.MyBean" ); $req->content_type( 'application/x-www-form-urlencoded' );
$req->content( '<burlap:call><method>add</method><int>32000</int><int>-1000</int></burlap:call>' );
$DEBUG || print $req->as_string();
my( $res ) = $ua->request( $req );
if( $res->is_success )
{
print "Success\n"; $cookie_jar->extract_cookies( $res ); $DEBUG || print $cookie_jar->as_string() . "\n"; $DEBUG || print $res->headers_as_string(); $DEBUG || print $res->as_string();
} else {
print "Failed with error: " . $res->code();
}