users@jax-rpc.java.net

Re: Serialization Error Dynamic Invocation with custom objects

From: Dharam <dharmendrasankhla_at_YAHOO.COM>
Date: Mon, 02 Dec 2002 20:16:02 -0800

hi Lila
yes you can serialize and deserialize interface/abstract classes
with the JAXRPC ri, there is nothing like bug, u have to provide additional classes while u making ur WAR file. if u r using deploytool do one thing while creating WAR file at the end use Customize Model Settings option and in the Optional Model Settings use identify Referenced Classes... , here u can add ur additional classes

deployetool will generate serializer and deserializer for u.

and if u r using wscompile, requires that you specify in the
wscompile config file all of the subclasses that will be used at
run-time. You do this by adding <additionaType> elements. Here is an
example.
<?xml version="1.0" encoding="UTF-8"?>
<configuration
        xmlns="http://java.sun.com/xml/ns/jax-rpc/ri/config">
        <service name="Interface_service"
          targetNamespace="http://tempuri.org/wsdl"
          typeNamespace="http://tempuri.org/types"
          packageName="proxy">
        <interface name="proxy.Interface"
            servantName="proxy.InterfaceImpl"/>
     <typeMappingRegistry>
         <additionalTypes>
             <class name="proxy.HelloObject"/>
             <class name="proxy.HiObject"/>
          </additionalTypes>
      </typeMappingRegistry>
     </service>
</configuration>
and use wscompile with -server option so it will generate serializer and deserializer for ur additional classes.
hope this will help u out.
Regards
Dharam
 Lila <lilatene_at_HOTMAIL.COM> wrote:hi,

I am trying to pass custom objects / beans in JAX-RPC using
Dynamic Proxy invocation, but whenever I try this I get a
serialization error, telling me that no serializer is
registered for the custom class. I thought that JAX-RPC
should take care of generating and registering the serializer.
If I use a static client instead (generating stubs with
wscompile) everything works fine.

To get the simplest example possible of this problem, I
modified the Dynamic Proxy "Hello" example from the JWSDP
tutorial, adding a very simple HelloObject class and a
"sayHelloObject" method to the Interface and Implementation
classes.

Here is the source code for the HelloObject class:

package proxy;

public class HelloObject {

String value;

public HelloObject() {
}

public void setValue(String v) {
value = v;
}

public String getValue() {
return value;
}

public String toString() {
return "Hello Object with value: " + value;
}
}

And here is the sayHelloObject method:

public HelloObject sayHelloObject(String s) {
HelloObject ob = new HelloObject();
ob.setValue(s);
return ob;
}

If I call sayHelloObject from a static client everything works
fine, but if I run the dynamic proxy client I get the following
error:

serialization error: no serializer is registered for (null, {http://com.test/types/MyHello}HelloObject)
at com.sun.xml.rpc.encoding.DynamicInternalTypeMappingRegistry.getSerializer(DynamicInternalTypeMappingRegistry.java:62)
at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.initialize(SOAPResponseSerializer.java:72)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.initialize(ReferenceableSerializerImpl.java:47)
at com.sun.xml.rpc.client.dii.BasicCall.createRpcResponseSerializer(BasicCall.java:436)
at com.sun.xml.rpc.client.dii.BasicCall.getResponseDeserializer(BasicCall.java:410)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:279)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:96)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:68)
at $Proxy0.sayHelloObject(Unknown Source)
at hello.HelloClient.main(Unknown Source)

CAUSE:

no serializer is registered for (null, {http://com.test/types/MyHello}HelloObject)
at com.sun.xml.rpc.encoding.TypeMappingUtil.getSerializer(TypeMappingUtil.java:41)
at com.sun.xml.rpc.encoding.InternalTypeMappingRegistryImpl.getSerializer(InternalTypeMappingRegistryImpl.java:287)
at com.sun.xml.rpc.encoding.DynamicInternalTypeMappingRegistry.getSerializer(DynamicInternalTypeMappingRegistry.java:47)
at com.sun.xml.rpc.encoding.soap.SOAPResponseSerializer.initialize(SOAPResponseSerializer.java:72)
at com.sun.xml.rpc.encoding.ReferenceableSerializerImpl.initialize(ReferenceableSerializerImpl.java:47)
at com.sun.xml.rpc.client.dii.BasicCall.createRpcResponseSerializer(BasicCall.java:436)
at com.sun.xml.rpc.client.dii.BasicCall.getResponseDeserializer(BasicCall.java:410)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:279)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:96)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:68)
at $Proxy0.sayHelloObject(Unknown Source)

[I am using JWSDP 1.0.01 on Windows 2000].

If anyone can let me know what I am doing wrong here I would
really appreciate it. Is Dynamic Proxy invocation not
supported with custom types? or maybe there is some bug here?

thanks,

Lila

Keep India Moving


---------------------------------
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now