I am trying to send java bean instances over a network stream. I want marshal / unmarshal java instances with JAXB and normal OutputStream to drag it over the network.
The servers are waiting at a non-marshal point, but the client is already much further.
Server:
inputStream = new BufferedInputStream(this.socket.getInputStream()); outputStream = new BufferedOutputStream(this.socket.getOutputStream()); JAXBContext requestContext = JAXBContext.newInstance(this.requestClass); Unmarshaller unmarshaller = requestContext.createUnmarshaller(); @SuppressWarnings("unchecked") K request = (K) unmarshaller.unmarshal(inputStream);
Client:
JAXBContext messageContext = JAXBContext.newInstance(message.getClass()); Marshaller marshaller = messageContext.createMarshaller(); out = new BufferedOutputStream(socket.getOutputStream()); marshaller.marshal(message, out); out.flush(); waitForResponse();
EDIT: I switched to the normal output stream, but it is still blocked. Should I send a special signal to tell JAXB to stop disassembling? If I close the client's output stream, the message comes from the server side.
source share