943,653 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 988
  • Java RSS
Dec 16th, 2008
0

Serialization/Deserialization Error

Expand Post »
Hi..my aim is to serialize/deserialize my "SoapPair" class , that contains Axis MessageContext obj (SoapPair receives this from its constructor), not serializable object(when trying to normally serialize , it returns "axis MessageContext not serializable")..
How do I serialize/deser the SoapPair class?
Do I have to use SerializationContext/Deser context? How?
Thanks in Advance.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrepezzo is offline Offline
6 posts
since Dec 2008
Dec 16th, 2008
0

Re: Serialization/Deserialization Error

Can you post your codes ? How about WSDL ?
Reputation Points: 9
Solved Threads: 2
Light Poster
AlbertPi is offline Offline
33 posts
since Nov 2008
Dec 16th, 2008
0

Re: Serialization/Deserialization Error

Click to Expand / Collapse  Quote originally posted by AlbertPi ...
Can you post your codes ? How about WSDL ?
I'll show you the skeleton of SoapPair class. It receives from the constructor an Axis MessageContext (it's not manadatory...)..and from it divides the Soap message into header+body (2 get methods).
My aim is to serialize that class from a test main , using the 2 methods deserialize/serialized that I should override in the class.


Java Syntax (Toggle Plain Text)
  1. public class SoapPair{
  2.  
  3. public SoapPair(org.apache.axis.MessageContext mc) {}
  4.  
  5. public Message getLeft(){
  6. return leftmsg
  7. }
  8.  
  9. public Message getRight(){
  10. return rightmsg;
  11. }
  12.  
  13.  
  14. protected void _serialize(final OutputStream out) throws PostException {
  15. }
  16.  
  17.  
  18. public Message deSerialize(final InputStream in) throws PostException {
  19. }
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrepezzo is offline Offline
6 posts
since Dec 2008
Dec 16th, 2008
0

Re: Serialization/Deserialization Error

If your SoapPair class has any member variables, all of them have to be of a type that is serializable.
Reputation Points: 33
Solved Threads: 18
Junior Poster in Training
mahlerfive is offline Offline
77 posts
since Aug 2008
Dec 16th, 2008
0

Re: Serialization/Deserialization Error

Yes I know that...
the problem is that "MessageContext" of Axis is NOT serializable...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrepezzo is offline Offline
6 posts
since Dec 2008
Dec 17th, 2008
0

Re: Serialization/Deserialization Error

You need to mark the field of type MessageContext as transient so that the serialization mechanism doesn't attempt to serialize it. This only works if the state of the MessageContext has no significance whatsoever to the newly reconstituted SoapPair object. If it does, then you have to manually write out the state of the MessageContext object for which you will have to provide an implementation for readObject and writeObject methods for your SoapPair class.

But given that if the MessageContext class isn't Serializable , there might be a good reason behind it. Are you sure the MessageContext instance *really* constitutes the state of your SoapPair object? Also given that any context logically belongs to a given environment, serializing it or clubbing it with something which is meant to be serialized doesn't make much sense.
Last edited by ~s.o.s~; Dec 17th, 2008 at 9:47 am.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006
Dec 18th, 2008
0

Re: Serialization/Deserialization Error

Thanks for reply....my professor keep on telling me that I have to implement ser/deser methods using Axis's (vers.1) ...Like serialization context and so on...but I don't know from how to start..
Thanks in Advance
Reputation Points: 10
Solved Threads: 0
Newbie Poster
andrepezzo is offline Offline
6 posts
since Dec 2008
Dec 18th, 2008
0

Re: Serialization/Deserialization Error

I haven't worked with Axis so wouldn't know the context involved but like I previously suggested, either mark the field as transient or implement your own readObject and writeObject methods to get around the restriction. Search for 'serialization java' with the search engine of your choice and you should find something to get you started.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 719
Failure as a human
~s.o.s~ is offline Offline
8,871 posts
since Jun 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: missing return statement prob
Next Thread in Java Forum Timeline: Cone Formula





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC