I need to get Element object with request. I have ObjectFactory. I created an JAXBElement, and I need to marshall it to Element. Could anyone help me?
Firewalls are programmed so they forward back to the original device the answer to any tcp connection the device initiated.
The device behind the firewall must always be the one who initiates the connection.
The server is easy, just wait for connections in a pre-defined port, then create a new thread to handle each new incoming connection. That way the server can handle multiple connections at the same time.
Keep in mind that if the connection is idle for a long time, the firewall might lose the association with the original device. You can implement a keep alive mechanism or just close the connection every time your device is going to be idle.
2 回答
您可以编组到DOMResult
:
DOMResult res = new DOMResult();
marshaller.marshal(myJaxbElement, res);
Element elt = ((Document)res.getNode()).getDocumentElement();
除了伊恩的回答,我想首先创建一个文档,因为可以这样省略未经检查的演员表:
Document document =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
JAXB.marshal(jaxbElement, new DOMResult(document));
Element element = document.getDocumentElement();