Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:51:02+00:00 2026-05-29T08:51:02+00:00

I have a socket connection for an external system which accept commands and sends

  • 0

I have a socket connection for an external system which accept commands and sends results in XML. Every command and result is a standalone XML document.

Which Java parser (/combination) should i use to:

  • parse the stream continuously without closing the connection (i know it’s stupid, but i tried DOMParser in the past and it throws an exception when an another document root encountered on the stream which is perfectly understandable). I need something like: continously read the stream and when a document is fully received, do it’s processing. I don’t know how big the document is, so i need to leave to the parser to figure out the end of the document.
  • deserialize every incoming document into bean instances (similary like XStream does)
  • serialize command object to the output stream from annotated class instances (similarly like XStream does). I don’t want to use two separate libraries for sending and receiving.
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:51:04+00:00Added an answer on May 29, 2026 at 8:51 am

    Well… XStream.createObjectInputStream seems to be what you need. I’m not sure if the stream provided must enclose all objects into a root node, but anyway you could arrange an inputstreams that add some virtual content to accomodate to XStream needs. I’ll expand this answer later…

    http://x-stream.github.io/objectstream.html has some samples…

    Root node

    Indeed the reader needs a root node. So you need an inputstream that reads <object-stream> plus the real byte content, plus a </object-stream> at the end (if you mind about that end). Depending on what you need (inputstream, readers) the implementation can be slighly different but it can be done.

    Sample

    You can use SequenceInputStream to concatenate virtual content to the original inputstream:

    InputStream realOne = ..
    // beware of the encoding!
    InputStream root = new ByteArrayInputStream("<object-stream>".toBytes("UTF-8")); 
    InputStream all = new SequenceInputStream(root, realOne);
    
    xstream.createObjectInputStream(withRoot); // voi lá
    

    If you use readers… well. There must be something equivalent 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a flash (ActionScript 3.0) which uses socket connection to send data to
Using android 2.3.3, I have a background Service which has a socket connection. There's
Possible Duplicate: Java socket sends some data during connection to server I have two
hi i have a socket connection (server) developed with methods available in using System.Net.Sockets;
I have a TCP socket connection where I get byte array of data which
I have a application which uses socket connection to send and receive data from
I have some socket connection code that makes use of boost::asio which reads from
I have a problem with a Socket connection closing too fast. I was told
I have a server that listens for a connection on a socket: public class
I have a socket application which I can use in local network, at home.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.