Hi,
We work with XFire version 1.2.4, with dynamic clients.
We have a service with a method like:
public Map<String, List<SomeBean>> test(List<String> stringList)
For the client to be able to serialize / deserialize correctly the parameters
and return values, we register the types:
- list of String
- SomeBean
- list of SomeBean
- map of String to List of SomeBean
----------------------
AegisBindingProvider bindingProvider = (AegisBindingProvider) client
.getService().getBindingProvider();
TypeMapping tm = bindingProvider.getTypeMappingRegistry()
.getDefaultTypeMapping();
Type someBeanType = new BeanType();
someBeanType.setTypeClass(SomeBean.class);
someBeanType.setSchemaType(new QName(namespace, name));
tm.register(someBeanType);
Type listOfStringType = new CollectionType(new StringType());
listOfStringType.setTypeClass(List.class);
listOfStringType.setSchemaType(new QName(namespace, name));
tm.register(listOfStringType);
Type listOfBeansType = new CollectionType(someBeanType);
listOfBeansType.setTypeClass(List.class);
listOfBeansType.setSchemaType(new QName(namespace, name));
tm.register(listOfBeansType);
but when we do:
List<String> param = new List<String>();
param.add("testing");
Map result = client.invoke("test", new Object[] {param});
we get:
org.codehaus.xfire.fault.XFireFault: Couldn't get property {namespace}field1
from bean one. Nested exception is java.lang.IllegalArgumentException: object
is not an instance of declaring class
at org.codehaus.xfire.fault.XFireFault.createFault(XFireFault.java:89)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:79)
at org.codehaus.xfire.client.Client.invoke(Client.java:335)
at org.codehaus.xfire.client.Client.invoke(Client.java:349)
at TestXfire.main(TestXfire.java:88)
Caused by: org.codehaus.xfire.XFireRuntimeException: Couldn't get property
{namespace}field1 from bean one. Nested exception is
java.lang.IllegalArgumentException: object is not an instance of declaring
class
at
org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:446)
at
org.codehaus.xfire.aegis.type.basic.BeanType.writeObject(BeanType.java:377)
at
org.codehaus.xfire.aegis.type.basic.ArrayType.writeValue(ArrayType.java:293)
at
org.codehaus.xfire.aegis.type.collection.CollectionType.writeObject(Collectio
nType.java:103) at
org.codehaus.xfire.aegis.type.basic.ObjectType.writeObject(ObjectType.java:20
7) at
org.codehaus.xfire.aegis.AegisBindingProvider.writeParameter(AegisBindingProv
ider.java:222) at
org.codehaus.xfire.service.binding.AbstractBinding.writeParameter(AbstractBin
ding.java:273) at
org.codehaus.xfire.service.binding.WrappedBinding.writeMessage(WrappedBinding
.java:89) at
org.codehaus.xfire.soap.SoapSerializer.writeMessage(SoapSerializer.java:80)
at
org.codehaus.xfire.transport.http.HttpChannel.writeWithoutAttachments(HttpCha
nnel.java:56) at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.getByteArrayReques
tEntity(CommonsHttpMessageSender.java:388) at
org.codehaus.xfire.transport.http.CommonsHttpMessageSender.send(CommonsHttpMe
ssageSender.java:326) at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:
123) at
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48) at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
... 3 more
Caused by: java.lang.IllegalArgumentException: object is not an instance of
declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.
java:25) at java.lang.reflect.Method.invoke(Method.java:585)
at
org.codehaus.xfire.aegis.type.basic.BeanType.readProperty(BeanType.java:442)
... 19 more
After debuging with the XFire source code, we found that most likely our
problem originates form the fact the the TypeMappingRegistry holds the type
information in a hash map, having as key the class of the type. In our case,
this leads to the overwriting of the List<String> with the List<SomeBean>.
Is there a fix or a workaround for this?
Any help is really appreciated! Thank you!
Cheers,
Tudor
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email