Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending xml file from server to client dynamically.

 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why? It's the wrong approach.
 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how are you saying that its wrong?.
 
Tim Moores
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:Web services work over HTTP, not raw sockets.
 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HttpClient library is very useful for uploading files, assuming that the target server is accessible via HTTP.
 
sudharani Savadi
Ranch Hand
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
uploading is from drive to our website.
 
Tim Moores
Bartender
Posts: 2802
39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good Morning Tim,

I got the output. I am able to store it in webcontent folder. Thanks for your kind help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic