• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

best way to send xml

 
Priyanka Chaurishia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello There,

I want to do a http post using an object.

So I have method like this :
@POST
@Consumes("application/xml")
@Path("/update/update1")
public Response update(DomainClass scheduledTask) {

now with unit testing I am successfully able to do the update:

String newTask = "<DomainClass >"
+ "<field1>test.jar</field1>"
+ "</DomainClass >";

URL postUrl = new URL("http://server//update/update1");


HttpURLConnection connection = (HttpURLConnection) postUrl
.openConnection();
connection.setDoOutput(true);
connection.setReadTimeout(5000);
connection.setInstanceFollowRedirects(false);
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/xml");
OutputStream os = connection.getOutputStream();
os.write(newTask.getBytes());

I want to send the same object thru jsp any ideas how to do that ? converting form fields to xml string is way to go... but are there existing tools for that? I am looking here what people do usually?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This doesn't seem like anything that JSP would be used or useful for.
 
Priyanka Chaurishia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Than what is suggested approach... how will you send an xml ?What techs would you use ? Now I can write whole code to convert form data into xml string but I want to use some existing framework to do this .So how would you approach this ?
 
Saurabh Pillai
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain higher level functionality what you are trying to achieve? There may be some other way to do the same thing.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A simple and efficient approach would use File Transfer Protoccol (FTP) to send an XML-based file. An alternative would be to send the data as a message via messaging system.
 
Paul Clapham
Sheriff
Pie
Posts: 20729
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could even use code which looked a lot like what you wrote to upload the XML via HTTP POST, if that's the requirement. However the statement that JSP isn't the right place to put such code is still correct.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
File size is an important aspect to consider. XML-based data files greater than 1 GB typically are best sent via FTP. A small XML document can be sent effectively via HTTP or JMS-based message.
 
Priyanka Chaurishia
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for inputs guys. I think metadata exchange on both layers () is the way to go . Still trying to figure out how to do this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic