The moose likes I/O and Streams and the fly likes Printing POST message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Printing POST message" Watch "Printing POST message" New topic

Printing POST message

Tom Griffith
Ranch Hand

Joined: Aug 06, 2004
Posts: 275
Hello. If somebody has a minute, is there a way to print the contents of a POST message to the console, ie....

POST /EndorsementSearch HTTP/1.1
Content-Type: text/xml; charset="utf-8"
Content-Length: 261
SOAPAction: ""
<m:GetEndorsingBoarder xmlns:m="">

I can obviously print the httpresponse using a bufferedreader and setting up an InputStream on the response...but not sure about outbound POST messages. Thank you very much for reading this.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See if the Apache Commons HTTPClient package has anything to help. They have an HttpURLConnection replacement that may be a bit more open. I tried to write one once using a raw socket inside so I could do some weird stuff, and realized it would involve implementing a major chunk of the HTTP protocol. I found another way to meet my requirements. You might, too. Have you tried an HTTP sniffer like HttpLook? Or maybe a proxy? (I know zip about proxies, but they seem to live in the right place to print out everything that goes through.)
[ July 31, 2006: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Printing POST message
It's not a secret anymore!