PDA

View Full Version : JaxRpcPortProxyFactoryBean UnsupportedOperationException



mcantrell
Aug 24th, 2005, 02:59 PM
I'm trying to create a webservice client using Spring's framework and I'm hitting a bit of a snag. I've extended JaxRpcPortProxyFactoryBean so I can provide mappings for my complex types:



package com.mycompany.myapp.service.util;

import org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean;
import org.jboss.axis.encoding.ser.BeanSerializerFactory;
import org.jboss.axis.encoding.ser.BeanDeserializerFactor y;

import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.rpc.encoding.TypeMappingRegistry;
import javax.xml.rpc.Service;
import javax.xml.namespace.QName;

import com.mycompany.myapp.domain.model.PosOrder;
import com.mycompany.myapp.domain.model.PosDetail;
import com.mycompany.myapp.domain.model.PosHeader;

public class PosPortProxyFactoryBean extends JaxRpcPortProxyFactoryBean {
protected void postProcessJaxRpcService(Service service) {
TypeMappingRegistry registry = service.getTypeMappingRegistry();
TypeMapping mapping = registry.createTypeMapping();
registerBeanMapping(mapping, PosOrder.class, "PosOrder");
registerBeanMapping(mapping, PosDetail.class, "PosDetail");
registerBeanMapping(mapping, PosHeader.class, "PosHeader");
registry.register("http://schemas.xmlsoap.org/soap/encoding/", mapping);
}

protected void registerBeanMapping(TypeMapping mapping, Class type, String name) {
QName qName = new QName("http://com.mycompany/", name);
mapping.register(type, qName,
new BeanSerializerFactory(type, qName),
new BeanDeserializerFactory(type, qName));
}

}


When I try to run my client, I see the following exception:



org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'storeWsClient' defined in class path resource [store-context.xml]: Initialization of bean failed; nested exception is java.lang.UnsupportedOperationException: Components should not use the getTypeMappingRegistry() method.
java.lang.UnsupportedOperationException: Components should not use the getTypeMappingRegistry() method.
at org.jboss.webservice.client.ServiceImpl.getTypeMap pingRegistry(ServiceImpl.java:173)
at com.mycompany.myapp.service.util.SonicPosPortProxy FactoryBean.postProcessJaxRpcService(SonicPosPortP roxyFactoryBean.java:22)
at org.springframework.remoting.jaxrpc.LocalJaxRpcSer viceFactory.createJaxRpcService(LocalJaxRpcService Factory.java:187)
at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.prepare(JaxRpcPortClientInterceptor. java:290)
at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.afterPropertiesSet(JaxRpcPortClientI nterceptor.java:268)
at org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean.afterPropertiesSet(JaxRpcPortProxyFac toryBean.java:55)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:348)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:226)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:269)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:317)
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;80&#41;
at org.springframework.context.support.ClassPathXmlAp plicationContext.<init>&#40;ClassPathXmlApplicationContext.java&#58;65&#41;
at org.springframework.test.AbstractSpringContextTest s.loadContextLocations&#40;AbstractSpringContextTests. java&#58;121&#41;
at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.loadContextLocations&#40;Abstract DependencyInjectionSpringContextTests.java&#58;159&#41;
at org.springframework.test.AbstractSpringContextTest s.getContext&#40;AbstractSpringContextTests.java&#58;101&#41;
at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp&#40;AbstractDependencyInjec tionSpringContextTests.java&#58;127&#41;
at com.intellij.rt.execution.junit2.JUnitStarter.main &#40;JUnitStarter.java&#58;31&#41;
at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Nativ e Method&#41;
at sun.reflect.NativeMethodAccessorImpl.invoke&#40;Native MethodAccessorImpl.java&#58;39&#41;
at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;De legatingMethodAccessorImpl.java&#58;25&#41;
at com.intellij.rt.execution.application.AppMain.main &#40;AppMain.java&#58;86&#41;


I see that the JSR921, section 4.2.2.9 states:



Components should not use the getTypeMappingRegistry&#40;&#41; method. A container provider must throw a java.lang.UnsupportedOperationException from the getTypeMappingRegistry&#40;&#41; method of the Service Interface.



http://www.jcp.org/aboutJava/communityprocess/maintenance/jsr921/websvcs-1_1-pd2.pdf

Is there another way to map these types with Spring in accordance with the specification?

ryan.tyer
Aug 26th, 2005, 08:29 AM
I am interested in this as well. Anyone know an answer to this?