You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Ian Minshall <ia...@blue8.uk.com> on 2002/09/13 11:36:30 UTC

Complex Structs within Structs

I have an application where I communicate between Axis (client) with MS SOAP TKv3 (server). I have to return structs from a COM object that contain other structs. The WSDL file generated seems ok but when I try to access it using AXIS i get an error that claims 'The parameter is incorrect'.

I think this is the parameter used in the deserializer to register the type deserializer. Note I only need deserializers.

eg. on the server is a struct like so

struct S1 {
	int 	id;
	BSTR	name;
	struct 	S2 myS2;
} S1;

struct S2 {
	int	id2;
	BSTR	name2
} S2;

on the client i have the following classes that accept the data

public class S1 {
	int	id;
	String	name;
	S2	myS2;
}

public class S2 {
	int	id2;
	String 	name2;
}

for the deserializer i register the following class;-

public class S1Deserializer extends DeserializerImpl {
    
    private Hashtable typesByMemberName = new Hashtable();
    
    public S1Deserializer() {
        typesByMemberName.put("id", Constants.XSD_INT);
        typesByMemberName.put("name", Constants.XSD_STRING);
        typesByMemberName.put("myS2", Constants.XXXXX);		<-------------------- What do I put here ???????????????????????????
        value = new S1();
    }
    
    public SOAPHandler onStartChild(String namespace, String localName,
                                    String prefix, Attributes attributes, DeserializationContext context) 
                                    throws SAXException {
        QName typeQName = (QName)typesByMemberName.get(localName);
        if (typeQName == null) {
            throw new SAXException("Invalid element in S1 struct - "+localName);
        }
        Deserializer dSer = context.getDeserializerForType(typeQName);
        try {
            dSer.registerValueTarget(new FieldTarget(value, localName));
        } catch(NoSuchFieldException ex) {
            throw new SAXException(ex);
        }
        if (dSer == null) {
            throw new SAXException("No deserializer for a "+typeQName+" ??");
        }
        return (SOAPHandler)dSer;
    }   
}

and S2 is similar but without the pointer to the sub-structure within it.

And they are registered as follows

            QName qname = new QName("http://tempuri.org/Caller/type/","S1");
            Class cls = S1.class;
            call.registerTypeMapping(cls, qname, axis.S1SerializerFactory.class, axis.S1DeserializerFactory.class);

            QName qname2 = new QName("http://tempuri.org/Caller/type/","S2");
            Class cls2 = S2.class;
            call.registerTypeMapping(cls2, qname2, axis.S2SerializerFactory.class, axis.S2DeserializerFactory.class);

(There are associated factory classes to create the Deserializer and Serializer classes)

So what is the missing parameter that I need to register a sub-structure within this structure?

regards

Ian Minshall