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 6052281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:54:41+00:00 2026-05-23T07:54:41+00:00

I currently have to store a Java object of a class that is not

  • 0

I currently have to store a Java object of a class that is not implementing Serializable but is surely SOAP-serialized because was generated from a WSDL and is the input of a web service.

Standard Java serialization, in fact, throws exception. I have no control over the classes, and the guys who created the classes are not willing to mark them Serializable by hand, because proxies were automatically generated from the WSDL (wsdl2java? They haven’t told me…).

So I need to transform that object into something else by not possibly cycling over each field.

The .class files show the XML serialization attributes, so I suppose they are definitely XML-serializable.

How to perform manual XML serialization of a Java object? I can do that in C# but not in Java.

Thank you

  • 1 1 Answer
  • 0 Views
  • 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-23T07:54:41+00:00Added an answer on May 23, 2026 at 7:54 am

    You can do

     private byte[] encode(YourObject obj)
        {
            byte[] bytes = null;
            try
            {
                YourObject vsNew = new YourObject(obj)
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    GZIPOutputStream out = new GZIPOutputStream(baos);
                    XMLEncoder encoder = new XMLEncoder(out);
                    encoder.writeObject(vsNew);
                    encoder.close();
                    bytes = baos.toByteArray();
            }
            catch (Exception e)
            {
                _log.error("Exception caught while encoding/zipping ", e);
            }
            return bytes;
        }
    
    
        /*
         * Decode the report definition blob back to the
         * ScheduledReport object.
         */
        private YourObject decode(byte[] bytes)
        {
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            YourObject vSNew = null;
            try
            {
                GZIPInputStream in = new GZIPInputStream(bais);
                XMLDecoder decoder = new XMLDecoder(in);
                vSNew = (YourObject)decoder.readObject();
                decoder.close();
            }
            catch (Exception e)
            {
                _log.error("IOException caught while decoding/unzipping ", e);
            }
            return vSNew ;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several Sets that store the objects of the same class, but I
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized
I'm currently playing with implementing various sorting algorithms in Java, mostly for fun, but
I currently have 4 textboxes which will be used to store an ip address.
We currently have an application that depends largely on stored procedures. There is a
I have a stored procedure currently executing a complicated fetch that is frequently timing
I have a database with DateTime fields that are currently stored in local time.
I currently have an MS Access application that connects to a PostgreSQL database via
I am creating a web app that requires the use of a Java Object
I have to install object store for a school project and it doesn't work

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.