5 # perl testKohaWS.pl http://eowyn.metavore.com:8001/cgi-bin/koha/svc cfc cfc 0.5 5 records/xml/xml-recs.xml
7 # POSTs to baseurl x number of times with y secs of delay between POSTs
10 # http://eowyn.metavore.com:8001/cgi-bin/koha/svc = baseurl
13 # 0.5 = sleep(0.5) between POSTs
14 # 5 = number of times to poast
15 # records/xml/xml-recs.xml = file of 1 marcxml record to post
17 # Requires LWP::UserAgent, File::Slurp.
19 use File::Slurp qw( slurp );
20 my $ua = LWP::UserAgent->new();
21 $ua->cookie_jar({ file =>"cookies.txt" });
26 my $timestopost = shift;
29 my $xmldoc = slurp($xmlfile) or die $!;
31 my $resp = $ua->post( $baseurl . '/authentication' , {userid =>$userid, password => $password} );
32 if( $resp->is_success ) {
37 die $resp->status_line;
40 for( my $i = 0; $i < $timestopost; $i++) {
41 warn "posting a bib number $i\n";
42 #warn "xmldoc to post: $xmldoc\n";
43 my $resp = $ua->post( $baseurl . '/new_bib' , 'Content-type' => 'text/xml', Content => $xmldoc );
44 if( $resp->is_success ) {
45 print "post to new_bib response:\n";
49 die $resp->status_line;