It sounds to me as if you are confusing two different things.
IWS (which uses QWSERVICE as a default userid, and runs under Java, explaining the reason you're getting these Java errors) does not require you to write data to STDOUT.
IWS does all of the XML/JSON work for you, and passes you input/output as parameters.
If you want to read/write your documents yourself using stdin/stdout, do not use IWS, but instead using a normal Apache server. (i.e. an HTTP server, NOT a web services server.)
My documents have examples of both ways, and it sounds like you are confusing the two.