You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Dan Steenblik <da...@cimsoft.com> on 2000/08/08 02:04:43 UTC

XMLSerialization

Hi,
I'm a bit new to Xerces, and I am having some problems with the
XMLSerializer.  I am able to  serialize my xml Document object to a file
using the XMLSerializer, but when I attempt to reconstitute my object I get
a java.io.OptionalDataException in the ObjectInputStream.readObject()
method.  I've included my small bit of code below...

Also, in playing around with this problem, I tried simply writing out my
Document object directly and reading it back in.  This seems to work
flawlessly, so I am confused about the reasons for using the Serializer
classes at all.  Would someone mind explaining this to me?

Lastly, ultimately I would like to use xerces and xml to pass data back and
forth from my EJBs and rmi objects.  With that in mind, what would be my
best bet for passing my xml chunks?  As a serialized w3c.dom.Document?  As a
serialized String object?  Some other kind of streaming?  Chances are, most
of my XML documents will be fully formed before any messaging takes place.

I'd appreciate the pointers.
Thanks,
--
Dan Steenblik
Software Developer,
Cimarron Software, Inc.
dan@cimsoft.com

My code:
public Test( String xmlUri, String serializedObjectFileName )
	throws Exception
{
	System.out.println( "Start Test" );
	DOMParser parser = new DOMParser();
	parser.parse( xmlUri );
	org.w3c.dom.Document doc = parser.getDocument();

	// try serialization
	ObjectOutputStream out =
		new
ectOutputStream( 
			new FileOutputStream( serializedObjectFileName ) );

	XMLSerializer serializer = new XMLSerializer( out, null );
	serializer.serialize( doc );
	//out.writeObject( doc );
	out.close();
		
	// try reading in serialized object
	ObjectInputStream in = 
		new ObjectInputStream(
			new FileInputStream( serializedObjectFileName ) );

	Document doc2 = (Document)in.readObject(); // throws java.io.OptionalDataException 
	in.close();
}



RE: XMLSerialization

Posted by Dan Steenblik <da...@cimsoft.com>.
Thanks, we've looked at soap (a little), but it is not an option for the
development we are doing.  I appreciate the response.
-dan

-----Original Message-----
From: Charles Brown [mailto:cnkbrown@twcny.rr.com]
Sent: Monday, August 07, 2000 8:18 PM
To: xerces-j-dev@xml.apache.org
Subject: RE: XMLSerialization



   I'm a bit new, too.  To me it sounds like you might be interested in
the SOAP protocol.  That's a sort of RMI, but it passes XML data using
via HTTP.  Take a look at http://xml.apache.org/soap/index.html

>
> Lastly, ultimately I would like to use xerces and xml to pass
> data back and
> forth from my EJBs and rmi objects.  With that in mind, what would be my
> best bet for passing my xml chunks?  As a serialized
> w3c.dom.Document?  As a
> serialized String object?  Some other kind of streaming?  Chances
> are, most
> of my XML documents will be fully formed before any messaging takes place.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


RE: XMLSerialization

Posted by Charles Brown <cn...@twcny.rr.com>.
   I'm a bit new, too.  To me it sounds like you might be interested in
the SOAP protocol.  That's a sort of RMI, but it passes XML data using
via HTTP.  Take a look at http://xml.apache.org/soap/index.html

>
> Lastly, ultimately I would like to use xerces and xml to pass
> data back and
> forth from my EJBs and rmi objects.  With that in mind, what would be my
> best bet for passing my xml chunks?  As a serialized
> w3c.dom.Document?  As a
> serialized String object?  Some other kind of streaming?  Chances
> are, most
> of my XML documents will be fully formed before any messaging takes place.
>