Don,
I've been playing a lot with custom serialization lately. I'll provide below
an example of a service returning an array of a custom class. The example
was built in Axis 1.2.1 and JDK 1.5.0_02.
I'm assuming you know how to handle the (de)serialization of the custom class.
If not, query this list as I put some examples of this up in the last week or
two.
My service has this method (simplified)
public CheckOutRec[] checkOutList()
{
CheckOutRec [] ckoutArr = ... call to legacy system returning array
return ckoutArr;
}
My client code looks like
void checkOutList (
Call call )
throws Exception
{
try
{
call.setOperationName( "checkOutList" );
// Register my custom class (de)serializers
call.registerTypeMapping( CheckOutRec.class,
OASQNames.checkOutRecQName,
CheckOutRecSerFactory.class,
CheckOutRecDeserFactory.class );
// Register array (de)serializers; note different QName
// from above.
ArraySerializerFactory asf =
new ArraySerializerFactory(CheckOutRec.class,
OASQNames.checkOutRecQName);
ArrayDeserializerFactory adf =
new ArrayDeserializerFactory(OASQNames.checkOutRecQName);
call.registerTypeMapping( CheckOutRec[].class,
OASQNames.checkOutRecArrQName,
asf.getClass(),
adf.getClass() );
// Set return type; note QName used in array
// registration above
call.setReturnType( OASQNames.checkOutRecArrQName );
CheckOutRec [] ret = (CheckOutRec []) call.invoke(
new Object[] {} );
if ( ret == null )
{
System.out.println( "Received null" );
}
else
{
System.out.println( "checkOutList:" );
for ( int i = 0; i < ret.length; i++ )
{
System.out.println( " - objectName: " + ret[i].objectName );
}
}
call.removeAllParameters();
}
catch ( RemoteException e )
{
System.err.println( "Caught RemoteException: " + e.getMessage() );
}
}
In my deploy.wsdd, I've type mapped only my custom type, not the array:
<typeMapping qname="ns:oasSoapNamespace" xmlns:ns="urn:oasSoapNamespace"
languageSpecificType="java:com.optix.database.CheckOutRec"
type="java:com.optix.database.CheckOutRec"
serializer="com.optix.soap.encoding.CheckOutRecSerFactory"
deserializer="com.optix.soap.encoding.CheckOutRecDeserFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
Let me know if this helps. It's my intent to write up what I've learned about
custom serialization for the User's Manual so any input is valuable.
On Wednesday 17 August 2005 15:57, Chen, Donald wrote:
> I am a newbie of Axis and looking for code examples of WS(both service
> and client) which has input parameters like array and/or hash, and
> return types like array/hash.
>
> I found no such samples included in the Axis release.
>
> Any type clue(such as a URL) will be appreciated!