aspose file tools*
The moose likes Distributed Java and the fly likes sending xml file from server to client dynamically. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "sending xml file from server to client dynamically." Watch "sending xml file from server to client dynamically." New topic
Author

sending xml file from server to client dynamically.

sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

Hi experts,

I need a help from you people. I am developing a project in that I have to get the data from the database dynamically and create XML file then send it to the client. we got to know that how to get data from the database and generating XML file from that data but my actual problem is how to send that XML file to a client. One more question is, my teammate is suggesting me to go for web services so is it necessary to go for web services or we can do it by using jsp and servlet?. Please help me out as soon as possible.


thanks in advance
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12821
    
    5
Seems to me we are missing the important information - what is the client?

In "web service" terms, this could easily be a RESTful style service which responds to a HTTP GET request with a HTTP response containing the XML as the body of the response.

Bill
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

Good Morning,

The client is android application. We are using RSS feed technology for reading the xml file data. In the beginning android application sends a request to the server for requesting xml file which contains a particular patient information i.e about patient and tablet scheduling,this information is available in the database.I am not getting how to send xml file which is stored on tomcat's application directory.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How are you handling the request on the server? You would send that as part of the HTTP response. What do you have so far?
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

Yeah. even I am saying that only but my teammate is telling that they will access the file by using socket. i do not know what to do.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Web services work over HTTP, not raw sockets. What you should do is explain this to your colleague; if that's the same one who suggested web services to you in the first place you should have no problems with that.
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1478
    
    6

As Tim has said, http request-response seems best for this, as overhead is less. Socket seems good if it is one to one communication. If multiple android devices connect to server with socket approach the server has to be multithreaded, but in http based design server can handle that. Correct me if I am wrong.


Swastik
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

finally what i thought is I am going to create socket which is a part of the server and it is responsible for sending xml file to android application. i hope it will work.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Why? It's the wrong approach.
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

how are you saying that its wrong?.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Tim Moores wrote:Web services work over HTTP, not raw sockets.
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

we are not using web-services. i think you have got to know what is my requirement. If yes, suggest me.



Have a good time.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Using raw sockets (on arbitrary ports) will not go down well with your network/system administrators. Better check with them if it's OK. There's a reason why HTTP-based solutions on port 80 are so popular.

If you're set to use raw sockets, then what is the problem in implementing that? Sockets transfer raw bytes, files consist of raw bytes, there's no principal difficulty here.
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

Hi Tim, can you suggest me how to upload a xml file to the website. Based on incoming request I will have to generate a xml file and upload it to website. I am able to generate xml file and storing in the hard drive but what I want is to upload it to the website.



Thank you.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
The HttpClient library is very useful for uploading files, assuming that the target server is accessible via HTTP.
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

HttpClient is used for sending a client data to a server. I will explain you about the project. Whenever a patient sends a request to the server, on that request I will fetch the prescription details from the database and I will generate xml file, i am not able store it in application's root directory of tomcat's webapps's folder. I am storing xml file in hard drive. If I store it in root directory, android application directly fetches the details through RSS Feed.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I'm confused. Your last question was about uploading a file. Now you're apparently asking about a mobile device downloading a file? Which one is it? And what, exactly, is the problem?
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

uploading is from drive to our website.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
By supplying so little information you're making it hard for us to help you. What machine is the drive connected to? How is it accessible from the server, or how is the server accessible from the machine the drive is connected to? Where do you want to run the code that does any of this file shuffling? Remember that we know nothing about your environment.
sudharani Savadi
Ranch Hand

Joined: Feb 23, 2011
Posts: 30

Good Morning Tim,

I got the output. I am able to store it in webcontent folder. Thanks for your kind help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: sending xml file from server to client dynamically.