public class XMLReceiver { public static Document receive(InputStream channel) throws ParserConfigurationException, TransformerConfigurationException, IOException, SAXException { DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); Document request = null; XMLInputStream xmlin = new XMLInputStream(channel); xmlin.recive(); request = docBuilder.parse(xmlin); return request; } }
public class XMLSender { public static void send(Document tosend, OutputStream channel) throws TransformerConfigurationException, IOException { XMLOutputStream out = new XMLOutputStream(channel); StreamResult sr = new StreamResult(out); DOMSource ds = new DOMSource(tosend); Transformer tf = TransformerFactory.newInstance().newTransformer(); try { tf.transform(ds, sr); } catch (TransformerException ex) { Logger.getLogger(XMLSender.class.getName()).log(Level.SEVERE, null, ex); } out.send(); } }
XMLOutputStream xmlOutput = new XMLOutputStream(stream); xmlOutput.writeObject(mappingClass); xmlOutput.close();
XMLInputStream xmlInput = new XMLInputStream(stream, getClass().getClassLoader()); (MappingClassElement)xmlInput.readObject(); xmlInput.close();
XMLOutputStream xmlOutput = new XMLOutputStream(stream); xmlOutput.writeObject(mappingClass); xmlOutput.close();
XMLInputStream xmlInput = new XMLInputStream(stream, getClass().getClassLoader()); (MappingClassElement)xmlInput.readObject(); xmlInput.close();