You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@ws.apache.org by ra...@materna.de on 2001/03/14 14:29:07 UTC
How to serialize a complex Object?
My question is about serialization of complex objects.
I have a container object which holds arrays and vectors. I can serialize
the
container object as a java bean, however, because the contents are arrays
and
vectors I get an error message that I need to use an array serializer for
the
arrays stored within the container class.
So my question is how do I use different serializers within one complex
object?
Any help is appreciated - thanx in advance.....
Rafael Stalitza
Business Unit Communications
----------------------------------------------------------------------------
--------
MATERNA GmbH Information & Communications
Im Defdahl 7 * 44141 Dortmund * Germany
phone : +49 231 5599 8679
eMail : rafael.stalitza@materna.de
http://www.materna.com * http://www.materna.de
------------
-- Source
--------------------------------------------------------------------------
// My Object I want to send
public class Q
{
QP mParameter;
QRS mResultSet;
long aLong;
String[] mSearchPattern;
// Functions to set and get the variables follows ..
}
public class QP //Parameter
{
String aString;
int aInt;
long aLong;
// Functions to set and get the variables follows ..
}
public class QRS //ResultSet
{
Vektor QRI;
public QRI[] getArray() { ... }
public getVector ...
public setVector ...
// Functions to set and get the variables follows ..
}
public class QRI //ResultItem
{
long aLong;
String aString;
}
---------------------------------------------
// a part of the ClientClass
SOAPMappingRegistry smr = new SOAPMappingRegistry();
BeanSerializer beanSer = new BeanSerializer();
smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("urn:xml-User", "User"),
User.class, beanSer, beanSer);
Call call = new Call();
call.setSOAPMappingRegistry(smr);
call.setTargetObjectURI("urn:User");
call.setMethodName(methodName);
call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
Vector params = new Vector();
if (args!=null)
{
for (int i=0; i<args.length; i++)
{
params.addElement(new Parameter( ("letter"+i), args[i].getClass(),
args[i], null));
}
}
call.setParams(params);
Response resp = null;
try
{
resp = call.invoke(url, "" );
(...)