Using XMLBeans binding for JAX-WS web services
weiqigao Oct 12, 2012 4:56 PMHi,
My last post in this forum was made six years ago. How's everybody?
I need to port some JAX-WS web services that use XMLBeans as the data binding from another application server. I'm using JBoss AS 7.0.2 Final, but I could be using JBoss 7.1.1 Final as well.
I searched the forum and other internet sites and understand that this is possible in some twisted way. My development process will be a
"Schemas for the parameters and return types first, generate XMLBeans for them using XMLBeans. Then Java first using the XMLBeans in service methods and depends on the runtime to generate the WSDL."
I have a prototype of this development flow working with plain Apache CXF. The trick is to put an CXF annotation onto the SEI class:
@javax.jws.WebService
@org.apache.cxf.annotations.DataBinding(import org.apache.cxf.xmlbeans.XmlBeansDataBinding.class)
public interface Demo {
DemoResponseDocument foo(DemoRequestDocument request);
}
where DemoRequestDocument and DemoResponseDocument are XMLBeans generated classes from the schema.
And I'm trying to deploy it in JBoss. I noticed that the cxf-rt-databinding-xmlbeans-2.4.1.jar is not included in the JBoss AS 7.0.2 Final distribution. The XMLBeans jar is also absent from the distrubution. I did put the cxf-rt-databinding-xmlbeans-2.4.1.jar file into the proper place and updated the module.xml file. I put the xmlbeans-2.4.0.jar into my WEB-INF/lib directory. When I deployed it into JBoss AS 7.0.2 Final, I got the following error that I did not see when I run it with CXF directly:
15:49:15,623 INFO [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-13) register: jboss.ws:context=demo,endpoint=Demo
15:49:15,628 INFO [org.apache.cxf.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-13) Creating Service {http://foo.com/}Demo from class foo.Demo
15:49:15,631 INFO [org.jboss.ws.common.management.DefaultEndpointRegistry] (MSC service thread 1-13) remove: jboss.ws:context=demo,endpoint=Demo
15:49:15,632 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-13) MSC00001: Failed to start service jboss.deployment.unit."demo.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."demo.war".INSTALL: Failed to process phase INSTALL of deployment "demo.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [:1.7.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [:1.7.0_07]
at java.lang.Thread.run(Thread.java:722) [:1.7.0_07]
Caused by: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Service class foo.Demo method total part {http://foo/}DemoRequest cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:350)
at org.jboss.wsf.stack.cxf.deployment.EndpointImpl.doPublish(EndpointImpl.java:88)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:239)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:509)
at org.jboss.wsf.stack.cxf.configuration.NonSpringBusHolder.configure(NonSpringBusHolder.java:116)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.startDeploymentBus(BusDeploymentAspect.java:109)
at org.jboss.wsf.stack.cxf.deployment.aspect.BusDeploymentAspect.start(BusDeploymentAspect.java:132)
at org.jboss.as.webservices.deployers.AspectDeploymentProcessor.internalDeploy(AspectDeploymentProcessor.java:79)
at org.jboss.as.webservices.deployers.TCCLDeploymentProcessor.deploy(TCCLDeploymentProcessor.java:42)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Service class foo.Demo method total part {http://foo/}DemoRequest cannot be mapped to schema. Check for use of a JAX-WS-specific type without the JAX-WS service factory bean.
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createBareMessage(ReflectionServiceFactoryBean.java:1164)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:449)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:682)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:501)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:241)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:202)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:157)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:202)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:433)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:322)
... 14 more
What am I missing? I'd appreciate any helps or pointers.