It's not a secret anymore!
The moose likes Web Services and the fly likes Help with approach to problem - HTTP POST to upload an XML file to URL Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Help with approach to problem - HTTP POST to upload an XML file to URL" Watch "Help with approach to problem - HTTP POST to upload an XML file to URL" New topic
Author

Help with approach to problem - HTTP POST to upload an XML file to URL

Terry Chambers
Greenhorn

Joined: May 11, 2009
Posts: 17
I have an XML file that I need to be able to upload, via HTTP POST, to a known URL which will accept the file and process it.

I am not sure of the process that I need to take. For example, to "upload a file", do I need to read the file in line by line and then upload it line by line or is there a way to just specify a local file and then upload it?

If you can give me some direction, that would be great.

Thanks
Terry
Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Kind of depends on the client interface.
If you're going to use a browser and have a user manually select the file, then no, you don't need to read the file at all on the client side. Just make use of one of the file upload utilites available:

commons fileUpload

http jsp file upload search

If this is for a web service or you're not going to use a browser for th UI, you may need to take a different approach though.
Terry Chambers
Greenhorn

Joined: May 11, 2009
Posts: 17
Sorry, I guess that is important.

I was thinking of a command line application as it will be run on a schedule.
Lino Larios
Greenhorn

Joined: Jun 27, 2008
Posts: 28
Hi, my best guess could be use from java a tool like curl, write a method where call curl and as argument the xml file .



luck!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32833
    
    4
Moving thread: too difficult for "beginning". Not quite sure where to move it to. Sorry if I move it to the wrong place
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
You can very well use commons fileUpload in your programme which takes file location as argument from command line.


SCJP 1.5(97%) My Blog
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Help with approach to problem - HTTP POST to upload an XML file to URL
 
Similar Threads
Doubt in doPut and doPost
Problem with reading submitted document
HTTP Status 405 - HTTP method GET is not supported by this URL
Generating .dmp file thro' Java Process
Using commons-fileupload-1.2.1.jar to upload file to MySQL