axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Schweisguth <d...@schweisguth.org>
Subject ClassCastException with dynamic proxies and bean mapping?
Date Wed, 08 Oct 2003 22:00:52 GMT
Dear axis-users,

I'm able to call a service which returns a bean via Call, but not via
dynamic proxies. In the following test code, the block of code which uses
Call succeeds but the following block, which uses a Stub, fails with a
ClassCastException.

      // Create the service
      Service service = ServiceFactory.newInstance().createService(
         new URL(wsdlURL), new QName(serviceNamespaceURI, wsdlServiceName));

      // Register the type mapping
      TypeMappingRegistry typeMappingRegistry =
         service.getTypeMappingRegistry();
      TypeMapping typeMapping = typeMappingRegistry.getTypeMapping(
         SOAPConstants.URI_NS_SOAP_ENCODING);
      QName type = new QName("urn:Echo", StringWrapper.class.getName());
      typeMapping.register(StringWrapper.class, type,
         new BeanSerializerFactory(StringWrapper.class, type),
         new BeanDeserializerFactory(StringWrapper.class, type));

      // Make the call via Call
      Call call = service.createCall();
      call.setTargetEndpointAddress(serviceURL);
      call.setOperationName(
         new QName(serviceNamespaceURI, "echoStringWrapper"));
      call.invoke(new Object[] { new StringWrapper("Hi Mom!") });

      // Make the call via Stub
      Stub stub = (Stub) service.getPort(Echo.class);
      ((Echo) stub).echoStringWrapper(new StringWrapper("Hi Mom!"));

StringWrapper is a test bean with a single String member. Note that in
both cases I'm ignoring the actual return value; the ClassCastException
in the latter occurs before the return. Here it is:

1) testEchoStringWrapperCall(Test)java.lang.ClassCastException
    at $Proxy0.echoStringWrapper(Unknown Source)
    at Test.testEchoStringWrapperCall(Test.java:68)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)

I inspected the return value in a debugger before it returned from the
InvocationHandler implementation. It appears to be a correctly initialized
StringWrapper, with the same ClassLoader as the StringWrapper in my test
code. Nonetheless, the error occurs. Can anyone suggest a solution?

Thanks,

-- 
| Dave Schweisguth                       http://www.schweisguth.org/~dave/ |
| Home: dave@schweisguth.org          Work: schweidc@appliedbiosystems.com |
| For compliance with the NJ Right to Know Act: Contents partially unknown |

Mime
View raw message