Hi Micah,

> I've patched http-access2 to accept the rest of the
> 2xx spectrum, but I guess now I'm stuck with a hacked
> copy of the library.

s/hacked/fixed/  :)

> Hopefully, very soon I will have a fully working plugin
> for Rails that will allow access to a Fedora repository
> in a similar way to ActiveRecord.

Excellent... I'm sure other folks using ruby would
find this useful.  When you're ready to share what you've
got, can you add a link to the wiki:
http://www.fedora.info/wiki/index.php/Utilities

Thanks,
Chris

-----Original Message-----
From: fedora-commons-users-bounces@lists.sourceforge.net on behalf of Micah Wedemeyer
Sent: Fri 6/29/2007 3:12 PM
Cc: Fedora-commons-users@lists.sourceforge.net
Subject: Re: [Fedora-commons-users] Posting to the upload servlet in  ruby

Hi Matt,

I was really hoping to hear from you, since it sounds like you're doing
a lot of Ruby/Fedora stuff with MediaShelf.

I played around with JRuby a few months ago and was not too pleased.
There were some errors (I can't remember exactly) with really basic
Rails stuff, and JRuby didn't play nicely with mongrel.  Plus, I'm a bit
of a coward when it comes to striking off on an unknown path.  I'm not
saying it's a bad idea, just not for me.

I have been having a little bit of success with http-access2 by Hiroshi
Nakamura, the same person who wrote SOAP4R.  It posts the file and gets
the response containing the "upload://" url that I so desperately want.
 Unfortunately, the upload servlet returns a status code of 201
"Created" and http-access2 assumes that all successes will return a 200.
 So, http-access2 bails out with an exception saying it got an
unexpected response.  Go figure :(

I've patched http-access2 to accept the rest of the 2xx spectrum, but I
guess now I'm stuck with a hacked copy of the library.  I submitted the
patch back to the http-access2 Trac site, so we'll see where that goes.

Hopefully, very soon I will have a fully working plugin for Rails that
will allow access to a Fedora repository in a similar way to
ActiveRecord.  I've documented some of my goals here:
http://blog.aisleten.com/2007/06/26/acts_as_fedora-a-rails-plugin-for-the-fedora-content-repository/

I hope to release it very soon, assuming there are no hurdles tossed in
the way by my legal department.

Thanks for the tips,
Micah


Matt Zumwalt wrote:
> Micah,
>
> I have never managed to get Ruby and the Upload servlet to play nice
> together.  Have you considered using JRuby so that you can just call the
> Java HTTP client classes directly? 
>
> Version 1.0 of JRuby is out.  It's been thoroughly tested and it's
> pretty darn easy to use.  If you've already got both Java and Ruby
> running on your system, it's a no brainer to set up.  Check out

> http://jruby.codehaus.org/
>
>
>
>
> Matt Zumwalt
> MediaShelf, LLC
> http://www.yourmediashelf.com
>
>
>
>
> On Jun 29, 2007, at 9:56 AM, Micah Wedemeyer wrote:
>
>> Mike,
>>
>> Thanks a lot for the links.  I had seen the one on realityforge, but I
>> just couldn't get it to work for me.  I get getting SOAP errors from the
>> upload servlet, but it didn't make any sense to me because I wasn't
>> using a SOAP call (to the best of my knowledge...)
>>
>> I think I will give the http-access2 a shot.  It seems to have worked
>> (with a patched version) for the person writing that HOWTO on the Rails
>> wiki.
>>
>> Here is a snippet of the request/response that I sent and got from the
>> upload servlet:
>>
>> Here's the request.  I'm trying to send the string "12345" as
>> text/plain, using a boundary of "99999999"
>>
>> <- "POST /fedora/services/upload HTTP/1.1\r\nAccept:
>> */*\r\nContent-Type: multipart/form-data,
>> boundary=99999999\r\nAuthorization: Basic
>> ZmVkb3JhQWRtaW46ZmVkb3JhQWRtaW4=\r\nContent-Length: 160\r\nHost:
>> localhost:8080\r\n\r\n"
>> <- "--99999999\r\nContent-Disposition: form-data; name=\"file\";
>> filename=\"file\"\r\nContent-Transfer-Encoding: binary\r\nContent-Type:
>> text/plain\r\n\r\n1234556\r\n--99999999--\r\n"
>>
>>
>> The response is a 500 like so:
>>
>> -> "HTTP/1.1 500 Internal Server Error\r\n"
>> -> "Content-Type: text/xml;charset=utf-8\r\n"
>> -> "Transfer-Encoding: chunked\r\n"
>> -> "Date: Thu, 28 Jun 2007 21:00:13 GMT\r\n"
>> -> "Server: Apache-Coyote/1.1\r\n"
>> -> "Connection: close\r\n"
>> -> "\r\n"
>> -> "228\r\n"
>> reading 552 bytes...
>> -> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope
>> xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"
>> xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
>> xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n
>> <soapenv:Body>\n  <soapenv:Fault>\n   <faultcode
>> xmlns:ns1=\"http://xml.apache.org/axis/\">ns1:Client.NoSOAPAction</faultcode>\n
>>   <faultstring>no SOAPAction header!</faultstring>\n   <detail>\n
>> <ns2:hostname
>> xmlns:ns2=\"http://xml.apache.org/axis/\">fortsave</ns2:hostname>\n
>> </detail>\n  </soapenv:Fault>\n </soapenv:Body>\n</soapenv:Envelope>"
>> read 552 bytes
>> reading 2 bytes...
>> -> "\r\n"
>> read 2 bytes
>> -> "0\r\n"
>> -> "\r\n"
>>
>> Formatted a little nicer (assuming e-mail doesn't mangle it):
>>
>> <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope
>> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>>  <soapenv:Body>
>>   <soapenv:Fault>
>>    <faultcode
>> xmlns:ns1="http://xml.apache.org/axis/">ns1:Client.NoSOAPAction</faultcode>
>>    <faultstring>no SOAPAction header!</faultstring>
>>    <detail>
>>     <ns2:hostname
>> xmlns:ns2="http://xml.apache.org/axis/">fortsave</ns2:hostname>
>>    </detail>
>>   </soapenv:Fault>
>>  </soapenv:Body>
>> </soapenv:Envelope>
>>
>>
>> If anyone has any ideas, please send them my way.
>>
>> Thanks again for the tips,
>> Micah
>>
>>
>> Michael J. Giarlo wrote:
>>> Documentation is Ruby's great weakness, for sure.
>>>
>>> Would you mind posting a snippet of code and an error message?
>>>
>>> I don't have working code to sure, but the problems you're running into
>>> might be due to lack of support for multipart forms in Net::HTTP.  It's
>>> puzzling why there is no multipart support, but there are some
>>> solutions.  Maybe one of these will help:
>>>
>>> http://raa.ruby-lang.org/project/http-access2
>>> http://www.realityforge.org/articles/2006/03/02/upload-a-file-via-post-with-net-http
>>> http://wiki.rubyonrails.org/rails/pages/HowToSendAFileByPostMultipart
>>>
>>> Best of luck, Micah.
>>>
>>> -Mike
>>>
>>>
>>> At 11:25 PT, 06/28/2007, Micah Wedemeyer wrote:
>>>>
>>>> Does anyone have any working Ruby code they'd be willing to share that
>>>> interacts with the upload servlet?  I have been banging my head against
>>>> the wall for several hours trying to figure out Net::HTTP and the upload
>>>> servlet.  Neither one has great documentation...
>>>>
>>>> Thanks,
>>>> Micah
>>>>
>>>
>>>
>>> -------------------------------------------------------------------------
>>> This SF.net email is sponsored by DB2 Express
>>> Download DB2 Express C - the FREE version of DB2 express and take
>>> control of your XML. No limits. Just data. Click to get it now.
>>> http://sourceforge.net/powerbar/db2/
>>> _______________________________________________
>>> Fedora-commons-users mailing list
>>> Fedora-commons-users@lists.sourceforge.net
>>> <mailto:Fedora-commons-users@lists.sourceforge.net>
>>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
>>>
>>>
>>
>>
>> -------------------------------------------------------------------------
>> This SF.net email is sponsored by DB2 Express
>> Download DB2 Express C - the FREE version of DB2 express and take
>> control of your XML. No limits. Just data. Click to get it now.
>> http://sourceforge.net/powerbar/db2/
>> _______________________________________________
>> Fedora-commons-users mailing list
>> Fedora-commons-users@lists.sourceforge.net
>> <mailto:Fedora-commons-users@lists.sourceforge.net>
>> https://lists.sourceforge.net/lists/listinfo/fedora-commons-users
>


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Fedora-commons-users mailing list
Fedora-commons-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fedora-commons-users