Serialization/Deserialization Error

Reply

Join Date: Dec 2008
Posts: 6
Reputation: andrepezzo is an unknown quantity at this point 
Solved Threads: 0
andrepezzo andrepezzo is offline Offline
Newbie Poster

Serialization/Deserialization Error

 
0
  #1
Dec 16th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 33
Reputation: AlbertPi is an unknown quantity at this point 
Solved Threads: 2
AlbertPi AlbertPi is offline Offline
Light Poster

Re: Serialization/Deserialization Error

 
0
  #2
Dec 16th, 2008
Can you post your codes ? How about WSDL ?
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 6
Reputation: andrepezzo is an unknown quantity at this point 
Solved Threads: 0
andrepezzo andrepezzo is offline Offline
Newbie Poster

Re: Serialization/Deserialization Error

 
0
  #3
Dec 16th, 2008
Originally Posted by AlbertPi View Post
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.


  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. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: mahlerfive is an unknown quantity at this point 
Solved Threads: 16
mahlerfive mahlerfive is offline Offline
Junior Poster in Training

Re: Serialization/Deserialization Error

 
0
  #4
Dec 16th, 2008
If your SoapPair class has any member variables, all of them have to be of a type that is serializable.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 6
Reputation: andrepezzo is an unknown quantity at this point 
Solved Threads: 0
andrepezzo andrepezzo is offline Offline
Newbie Poster

Re: Serialization/Deserialization Error

 
0
  #5
Dec 16th, 2008
Yes I know that...
the problem is that "MessageContext" of Axis is NOT serializable...
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Serialization/Deserialization Error

 
0
  #6
Dec 17th, 2008
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.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 6
Reputation: andrepezzo is an unknown quantity at this point 
Solved Threads: 0
andrepezzo andrepezzo is offline Offline
Newbie Poster

Re: Serialization/Deserialization Error

 
0
  #7
Dec 18th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Serialization/Deserialization Error

 
0
  #8
Dec 18th, 2008
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.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC