***** infoCopter.com/perl *****

https XML POST with LWP



up

#!/usr/bin/perl -w
use strict;

use LWP::UserAgent;
use HTTP::Request::Common;

use Net::SSL;
use LWP::Protocol::https;
use URI::https;

&main();

sub main() {
	my $ua = LWP::UserAgent->new(agent => 'xml client');

	my $resp = $ua->request(
		POST 'https://www.example.com/upp/jsp/XML_authorize.jsp' ,
		Content_Type  => 'application/x-www-form-urlencoded',

		Content       => [ xmlRequest =>
				q~<?xml version="1.0" encoding="UTF-8" ?>
				<authorizationService version="1">
				   <body merchantId="1000011011" testOnly="yes">
				     <transaction refno="1234987">
				       <request>
					 <amount>100</amount>
					 <currency>CHF</currency>
					 <cardno>4950000111111110</cardno>
					 <expm>11</expm>
					 <expy>04</expy>
				       </request>
				     </transaction>
				   </body>
			 </authorizationService>~
				]
	);

	print $resp->error_as_HTML unless $resp->is_success;

	print $resp->content();
}
© reto :)