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);
21 my $ua = LWP::UserAgent->new();
22 $ua->cookie_jar({ file =>"cookies.txt" });
27 my $timestopost = shift;
30 my $xmldoc = slurp($xmlfile) or die $!;
32 my $resp = $ua->post( $baseurl . '/authentication' , {userid =>$userid, password => $password} );
33 if( $resp->is_success ) {
38 die $resp->status_line;
41 for( my $i = 0; $i < $timestopost; $i++) {
42 warn "posting a bib number $i\n";
43 #warn "xmldoc to post: $xmldoc\n";
44 my $resp = $ua->post( $baseurl . '/new_bib' , 'Content-type' => 'text/xml', Content => $xmldoc );
45 if( $resp->is_success ) {
46 print "post to new_bib response:\n";
50 die $resp->status_line;