How to write XML file with Java and read it?

Rails/Java XML-RPC Filter

  • Railsfilter: I need to write an addition to an already-existing Rails app to allow it to accept large files (and some trivial metadata) uploaded from a Processing (Java) client I've written. The Rails app already supports this behavior via a web interface. I can see a few of the trees, how do I fit them into the forest and get a pair of working apps? I think I understand basic XML-RPC, but file uploading seems to be a different beast. There's also the question of XML-RPC vs. SOAP vs. REST -- REST seems to be the de facto Rails standard, but there doesn't seem to be much in the way of Java REST APIs, so I'm looking at XML-RPC as the path of least resistance because of its' support through Action Web Service. So, the question is, can someone please explain to me how file uploads through XML-RPC work? I've read about multi-part forms, base64 encoding and so forth but I'm not really sure how to put it all together. The Rails app is using file_column for uploads, if that helps.

  • Answer:

    You want cURL, and to use it to make REST calls.

Alterscape at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

I haven't used cURL before so I'm swimming through the docs right now and trying to get my bearings, but if I'm understanding this correctly, it looks like I'd need to have my app call libcurl, log into my server through sftp/ftp, and push the file up. I don't have the ability to create an unlimited number of user accounts and I'm uncomfortable with the idea of so I'd rather keep authorization running through the Rails app. Or am I completely misunderstanding how libcurl would be used in this context?

Alterscape

cURL seems weird for using in Java. Why not just a simple HTTP POST?

rbs

Well, yeah, since REST is all about HTTP POSTs and GETs anyway. There's a cURL wrapper out there, but you can certainly construct your own HTTP POSTS by hand if that floats your boat.

genghis

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.