G
Gordon Beaton
I am using XmlBeans v2 for a project where I need to send an xml
file through the network. I have a server that waits for incoming
requests, and a client that builds the xml, sends it to the server,
and then it waits for the response xml.
[...]
Now, the problem that I'm having is on the server. The parse()
method doesn't stop reading data from inputStream after the xml was
completely sent to it. So it keeps waiting for data, even if the
object on the client has finished sending data.
[...]
This problem is really nasty to me, since I want to be able to send
more data on the outputstream, from the client, after the xml was
sent. So, to close the outputstream after the xml was sent, it
doesn't really help me (and, moreover, if I close the outputstream,
I get a new exception when I try to close the socket or when I try
to read from the InputStream, which I think is natural).
It sounds to me like you have conflicting requirements. If parse()
needs to read to EOF, then your client needs to close the OutputStream
or at least call socket.shutdownOutput() before that can occur. On the
other hand if you need to send more data on the *same* stream, then
EOF is the wrong condition for parse() to be waiting for.
An alternative is to have the client open a new connection for each
request, and use socket.shutdownOutput() to signal EOF before reading
the response.
Another is to have the server read from the incoming stream to
intermediate storage, then create (for example) a
ByteArrayInputStream() that you can pass to parse().
/gordon