[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [handle-dev] RE: Batch uploading




Tim:

Here's the routine we're using. Hope this is of some use.

Tony


sub Deposit_DOI_and_Metadata {

  my ($Username, $Password, $Prefix, $XML_Dir, $XML_File) = @_;

  my $URL = 'http://deposit.crossref.org/xmlbatch/LoadXML';

# Create a user agent object

  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

# Pass request to the user agent and get a response back

  my $res = $ua->request(POST $URL, Content_Type => 'form-data', Content => [
                  login_id     => $Username,
                  login_passwd => $Password,
                  name_auth    => $Prefix,
                  fname        => ["$XML_Dir/$XML_File"],
                  operation    => 'Submit Batch File',
                ]);

# Check the outcome of the response - I guess we just file away

  if ($res->is_success) {
    print "CR: success!\n";
  } else {
    print "CR: failed!\n";
  }
}




Tim Keefer <tkeefer@allenpress.com>@cnri.reston.va.us on 20/02/2001
21:52:08

Sent by:  handle-dev-admin@cnri.reston.va.us


To:   CrossRef <handle-dev@cnri.reston.va.us>
cc:

Subject:  [handle-dev] RE: Batch uploading


Hi Steve,
Thanks for the advice. The CrossRef web site has a sample of an encoded
batch file.  I used the sample to construct my batch file, but what I
can't figure out is how to send this data using perl. No matter how I
try it, I always seem to get this error message: "Your XML batch
submission failed.  Upload error: java.lang.Exception: Zero-length or
missing file". I can't find any Perl documentation on multi-part form
data.  Can I ask you and the other veteran users on this list what
programming language they use to post this data? Does anyone know of any
Perl documentation that explains "LWP" and sending files using
multi-part form data. Thanks
Tim Keefer


There is a good article at:

http://perl.about.com/compute/perl/library/weekly/aa020600e.htm

on how to manipulate MIME content with Perl. It talks about email
messages,
but basically it should be the same thing for HTTP POSTing. The Perl
MIME
libraries will help you Base 64 encode the message, then you post it
using
the LWP modules, receive it on the other end, and then decode it...

HTH,

- steve

Stephen Petschulat
E-Business Architect
IBM Pacific Development Centre
4611 Canada Way
Phone: 1-604-297-3231

Hi all,
I am constructing a script to upload our XML metadata files to CrossRef.

At the meeting in New York Mark suggested that Perl's LWP module would
post the metadata file to CrossRef. I'm not exactly sure how this is
done. Below is some Perl code that I have put together that posts data
to the web server. Does anyone know how to post multi-part form data
using perl? I have looked through all the Perl books and they don't
touch on this topic. Any help is appreciated, thanks.

  # Create a user agent object
  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

  # Create a request
  my $req = new HTTP::Request POST =>
'http://deposit.crossref.org/xmlbatch/LoadXML';
  $req->content_type('multipart/form-data');

$req->content('$encodedfile');

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  if ($res->is_success) {
      print $res->content;
  } else {
      print "Unable to retrieve response\n";
  }

--
_____________________________________________________________________
Tim Keefer                                  Allen Press, Inc.
Electronic Publishing              1041 New Hampshire
http://www.allenpress.com        Lawrence, KS 66044
_____________________________________________________________________

--
_____________________________________________________________________
Tim Keefer                                  Allen Press, Inc.
Electronic Publishing              1041 New Hampshire
http://www.allenpress.com        Lawrence, KS 66044

-- I believe there is a subtile magnetism in nature,
   if we unconsciously yield to it, will direct us aright.  -- Thoreau
_____________________________________________________________________



_______________________________________________
handle-dev mailing list
handle-dev@cnri.reston.va.us
http://www.cnri.reston.va.us/mailman/listinfo/handle-dev




_______________________________________________
handle-dev mailing list
handle-dev@cnri.reston.va.us
http://www.cnri.reston.va.us/mailman/listinfo/handle-dev