Burlap: Perl Example

From Resin 3.0

Jump to: navigation, search
40px-Edit-clear.png This article requires cleanup and may refer to a legacy version of Resin.

Please visit http://www.caucho.com/documentation/ for the most up-to-date documentation.

  1. !/usr/bin/perl -w

use strict; use LWP::UserAgent; use HTTP::Cookies;

  1. 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();

}

Personal tools