Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
socket\KeepSocketOpen.java - Apache Xerves Socket Sample
What is the socket\KeepSocketOpen.java provided in the Apache Xerces package? I have Apache Xerces 2.11.0 installed.
✍: FYIcenter
socket\KeepSocketOpen.java provided in the Apache Xerces package
provides a solution to the problem of 1) sending multiple XML documents over
a single socket connection or 2) sending other types of data after the XML
document without closing the socket connection.
The first situation is a problem because the XML specification does not allow a document to contain multiple root elements. Therefore a document stream must end (or at least appear to end) for the XML parser to accept it as the end of the document.
The second situation is a problem because the XML parser buffers the input stream in specified block sizes for performance reasons. This could cause the parser to accidentally read additional bytes of data beyond the end of the document. This actually relates to the first problem if the documents are encoding in two different international encodings.
The solution that this sample introduces wraps both the input and output stream on both ends of the socket. The stream wrappers introduce a protocol that allows arbitrary length data to be sent as separate, localized input streams. While the socket stream remains open, a separate input stream is created to "wrap" an incoming document and make it appear as if it were a standalone input stream.
Here is how to run socket\DelayedInput.java, if you have Apache Xerces 2.11.0 installed:
\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\javac -cp ..\xercesImpl.jar;..\xercesSamples.jar socket\KeepSocketOpen.java Note: socket\KeepSocketOpen.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. C:\fyicenter\xerces-2_11_0\samples>\fyicenter\jdk-1.8.0\bin\java -cp .;..\xercesImpl.jar;..\xercesSamples.jar socket.KeepSocketOpen User.xml UserDTD.xml UserXSD.xml Server: Created. Client: Created. Server: Running. Client: Running. Server: Client connected. Server: Opening file "User.xml" Server: Wrote 226 byte(s) total. Server: Opening file "UserDTD.xml" Server: Wrote 411 byte(s) total. Server: Opening file "UserXSD.xml" Server: Wrote 411 byte(s) total. Server: Exiting. Client: Read 226 byte(s) total. Client: 2 ms (5 elems, 0 attrs, 0 spaces, 58 chars) Client: Read 411 byte(s) total. Client: 6 ms (5 elems, 0 attrs, 21 spaces, 37 chars) Client: Read 411 byte(s) total. Client: 2 ms (5 elems, 3 attrs, 0 spaces, 62 chars) Client: Exiting.
⇒ Using Apache Xerces Other Sample Programs
⇐ Read XML with Schema from Socket with socket\DelayedInput.java
2017-09-20, 10693🔥, 0💬
Popular Posts:
Apache Axis2 is the core engine for Web services. It is a complete re-design and re-write of the wid...
The JSR 105 XML Digital Signature 1.0.1 FCS implementation provides an API and implementation that a...
commons-io-1.4.jar is the JAR file for Commons IO 1.4, which is a library of utilities to assist wit...
How to download and install ojdbc14.jar for Oracle 10g R2? ojdbc14.jar for Oracle 10g R2 is a Java 1...
JDK 11 jdk.aot.jmod is the JMOD file for JDK 11 Ahead-of-Time (AOT) Compiler module. JDK 11 AOT Comp...