Making XML http post using java

Axoliien

Senior member
Mar 6, 2002
342
0
0
I did this a few years ago in college, where we were given a file and needed to read in the file, create a string, then send a post message to an http server which would pick up the string for use in a server app. Pretty common XML stuff today, which is what we are doing now. I have made a java application to pick up our XML file, read into a stringbuffer, connect to a url and send the message as a post request, but now I need to figure out how to actually test the application. We haven't been given the URL to post to yet since the target is being developed by an external entity. I haven't made a program before to actually read in the post info and use the data, so any suggestions where I can start to make an app or download one for my localhost to see what is being sent and ensure that all is going well?

I hope I am being clear enough!
 

mundane

Diamond Member
Jun 7, 2002
5,603
8
81
If I understand your request correctly, you should be able to make a java.net.ServerSocket, have it listen at your designated port, and then dump whatever http messages are sent that way. You should be able to analyze what is sent to make sure your client application is composing the http post correctly.

-Or, there must be some lightweight java webservers out there you could use, as well.
 

Axoliien

Senior member
Mar 6, 2002
342
0
0
thanks, the java.net.ServerSocket will be my first try then, I'll get back later and let you know!
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Fire up tomcat (or your servlet container of choice) and write a simple servlet that spits out the post parameters. More overhead than writing your own ServerSocket version, but it's less coding and will provide a much better validation given that it would actually use the http protocol.