• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending XML files using HTTP Request/Response?

 
Veni Velkoor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all!

I am not sure if this is the right forum for this question, please redirect me if this is not.

With that, here is a question ... from a novice really.

We have a situation where we need to send an XML file from our server to another server..URL really (http:// abc.com/xyz.crspx). This URL expects this XML file, reads and sends us back a response (with success or error codes etc) which I need to write to a file and save. The XML file itself contains the authentication information which the remote server will use before it sends a response back.

Is this something I should use HTTP Request/Response for. Can I do this in a batch mode where this program runs every 10 mts and picks up an XML file in a predetermined location and transmits it. Are there limitations to the size of the XML file.

Any direction on how to proceed will be very helpful. Suggestions & resources are appreciated.

Thanks much!
V
[ August 09, 2006: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are desribing (I think) is a file upload from one server to another. And yes, this can be performed using the request/response mechanism just as a file can be uploaded from a client to a server.

You'll need to make sure to follow the HTTP protocol carefully with regards to file uploading using a multi-part request.

First thing I'd do is to check out tools like HttpUnit to see if they have already done a lot of the heavy lifting for you.
 
Veni Velkoor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear!

I looked up HTTPUnit on Google for a bit. It looks like a framework for website testing and is quite comprehensive. But upon a first look, I couldn't find anything quite that relevant to what I am trying to do.

Could you, perhaps, recommend any other simpler resources that might help me get started on developing the Http request/response streams. The XML files that we plan to transmit may not be too big and atleast for the first pass, I hope to get them transmitted in one request without having to break them down and make it a multi-part transmission.

Thanks in Advancnce
Veni
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Veni Velkoor:

I looked up HTTPUnit on Google for a bit. It looks like a framework for website testing and is quite comprehensive. But upon a first look, I couldn't find anything quite that relevant to what I am trying to do.


Even though HttpUnit is a testing framework, it has tool classes that make it easy to initiate requests of various types under program control that are intended to be used when writing automated tests, but are also very useful for doing the types of things you are doing as well. What support they may have for file uploading requests, I do not know, but it's the first thing I'd check before striving out to write something on my own.

Setting out from scratch, I'd get a good handle on how to make HTTP multi-part requests and employ the URL and URLConnection classes.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ben Souther:
HttpClient supports file uploads too:
http://jakarta.apache.org/commons/httpclient/


Excellent!
 
Veni Velkoor
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben & Bear! That is some useful information.

I will check in to it and get back.

Have a good one!
V
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, HTTPUnit is more than a testing framework. I once used it to create a BOT that picks a randomn page from encylopedia (http://en.wikipedia.org/wiki/Special:Randompage), parse the text and post it in a forum every 2 minutes. Ah! that was fun....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!