You are using JAX-WS annotated interface. Use the JaxWsProxyFactoryBean
instead of the ClientProxyFactoryBean.
Dan
On Friday 29 October 2010 7:18:11 pm Joe Lin wrote:
> I corrected that problem. I need to setServiceClass for the factory but now
> when I tried to make an invokation at hello2.sayHello("yo!") I'm getting a
> "Caused by: javax.xml.bind.UnmarshalException: unexpected element
> (uri:"http://order.demo/", local:"arg0"). Expected elements are <{}arg0>".
>
> Any help?
>
> Following is the new code.
>
> @WebService(endpointInterface="demo.order.HelloService")
> public class HelloImpl implements HelloService {
>
> @Override
> public String sayHello(String name) {
> if ( name == null )
> name = "Nothing";
> // TODO Auto-generated method stub
>
> ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
> factory.setAddress("local://hello");
> factory.setServiceClass(HelloService.class); //<-----------
> need to
ass
> this
>
> HelloService hello2 = (HelloService) factory.create();
>
> Method[] methods = hello2.getClass().getDeclaredMethods();
>
> name = hello2.sayHello("yo!"); //<------------- JAXB problem
> here
>
> return "hello " + name ;
> }
>
> }
>
> --- On Fri, 10/29/10, Joe Lin <[email protected]> wrote:
> > From: Joe Lin <[email protected]>
> > Subject: Re: Problem using LocalTransport in Tomcat
> > To: [email protected], "Daniel Kulp" <[email protected]>
> > Date: Friday, October 29, 2010, 2:35 PM
> > Thanks. That works. But now I have a
> > new problem. Essentially what I'm trying to accomplish is to
> > call another service on LocalTransport from on of the
> > service. I have HelloImpl and HelloImpl2 all implements
> > HelloService. HelloImpl2 is the service on LocalTransport
> > and I'm trying to call HelloImpl2 from HelloImpl. But I'm
> > getting the following exception. It failed at
> > ClientProxyFactory.create():
> >
> > ============================================
> > at
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
> > at
> > org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTP
> > Servlet.java:159) at
> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applicat
> > ionFilterChain.java:290) at
> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilte
> > rChain.java:206) at
> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve
> > .java:233) at
> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve
> > .java:191) at
> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
> > 127) at
> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
> > 102) at
> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.j
> > ava:109) at
> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:29
> > 8) at
> > org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857
> > ) at
> > org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(H
> > ttp11Protocol.java:588) at
> > org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
> > at
> > java.lang.Thread.run(Thread.java:637)
> > Caused by: java.lang.NullPointerException
> > at
> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean.checkServiceC
> > lassAnnotations(ReflectionServiceFactoryBean.java:2340) at
> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean.setServiceCla
> > ss(ReflectionServiceFactoryBean.java:2337) at
> > org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.initializeServic
> > eFactory(AbstractWSDLBasedEndpointFactory.java:230) at
> > org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(A
> > bstractWSDLBasedEndpointFactory.java:100) at
> > org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:9
> > 0) at
> > org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryB
> > ean.java:105) at
> > demo.order.HelloImpl.sayHello(HelloImpl.java:19)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > at
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> > :39) at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> > mpl.java:25) at
> > java.lang.reflect.Method.invoke(Method.java:597)
> > at
> > org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(Abstract
> > Invoker.java:173) at
> > org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.jav
> > a:89) ... 30 more
> >
> > ============================================
> >
> > Below is my interface and implementation:
> >
> >
> > @WebService
> > public interface HelloService {
> >
> > @WebMethod
> > String sayHello(String name);
> > }
> >
> > @WebService(endpointInterface="demo.order.HelloService")
> > public class HelloImpl2 implements HelloService {
> >
> > @Override
> > public String sayHello(String name) {
> > if ( name == null )
> >
> > name = "Nothing Local";
> > // TODO
> > Auto-generated method stub
> > return "hello " +
> > name ;
> > }
> >
> > }
> >
> > @WebService(endpointInterface="demo.order.HelloService")
> > public class HelloImpl implements HelloService {
> >
> > @Override
> > public String sayHello(String name) {
> > if ( name == null )
> >
> > name = "Nothing";
> > // TODO
> > Auto-generated method stub
> >
> >
> > ClientProxyFactoryBean factory = new
> > ClientProxyFactoryBean();
> >
> > factory.setAddress("local://hello");
> >
> > HelloService hello2 =
> > (HelloService) factory.create();
> >
> > name =
> > hello2.sayHello("yo!");
> >
> > return "hello " +
> > name ;
> > }
> > }
> >
> >
> >
> >
> >
> >
> > --- On Fri, 10/29/10, Daniel Kulp <[email protected]>
> >
> > wrote:
> > > From: Daniel Kulp <[email protected]>
> > > Subject: Re: Problem using LocalTransport in Tomcat
> > > To: [email protected]
> > > Cc: "Joe Lin" <[email protected]>
> > > Date: Friday, October 29, 2010, 1:57 PM
> > >
> > > Hmm... Sounds like its not finding the transport
> > > factory for some reason.
> > >
> > > Can you add:
> > >
> > > transportId="http://cxf.apache.org/transports/local"
> > >
> > > to the jaxws:endpoint for the local one to force it?
> > >
> > > Dan
> > >
> > > On Friday 29 October 2010 4:52:06 pm Joe Lin wrote:
> > > > Thanks for the reply. Here is the full stack:
> > > >
> > > > Oct 29, 2010 12:22:39 AM
> > >
> > > org.springframework.web.context.ContextLoader
> > >
> > > > initWebApplicationContext SEVERE: Context
> > >
> > > initialization failed
> >
> > org.springframework.beans.factory.BeanCreationException:
> > > Error creating
> > >
> > > > bean with name 'helloLocal': Invocation of init
> >
> > method
> >
> > > failed; nested
> > >
> > > > exception is javax.xml.ws.WebServiceException:
> > > > java.lang.NullPointerException at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
> >
> > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
> >
> > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.createBean(AbstractAutowireCapableBeanFactory.java:456)
> >
> > > at
> >
> > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject
> > (
> >
> > > > AbstractBeanFactory.java:291) at
> >
> > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.ge
> > t
> >
> > > > Singleton(DefaultSingletonBeanRegistry.java:222)
> >
> > at
> >
> >
> > org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(A
> > b
> >
> > > > stractBeanFactory.java:288) at
> >
> > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Abs
> > t
> >
> > > > ractBeanFactory.java:190) at
> >
> > org.springframework.beans.factory.support.DefaultListableBeanFactory.preI
> > n
> >
> >
> > stantiateSingletons(DefaultListableBeanFactory.java:580) at
> >
> >
> > org.springframework.context.support.AbstractApplicationContext.finishBean
> > F
> >
> >
> > actoryInitialization(AbstractApplicationContext.java:895)
> >
> > > at
> >
> > org.springframework.context.support.AbstractApplicationContext.refresh(Ab
> > s
> >
> > > > tractApplicationContext.java:425) at
> >
> > org.springframework.web.context.ContextLoader.createWebApplicationContext
> > (
> >
> > > > ContextLoader.java:276) at
> >
> > org.springframework.web.context.ContextLoader.initWebApplicationContext(C
> > o
> >
> > > > ntextLoader.java:197) at
> >
> > org.springframework.web.context.ContextLoaderListener.contextInitialized(
> > C
> >
> > > > ontextLoaderListener.java:47) at
> >
> > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.ja
> > v
> >
> > > > a:4135) at
> >
> > org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
> >
> > > > at
> >
> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.jav
> > a
> >
> > > > :791) at
> >
> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
> >
> > > at
> >
> > org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
> >
> > > at
> >
> > org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905)
> >
> > > at
> >
> > org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
> >
> > > at
> >
> > org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
> >
> > > at
> >
> > org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
> >
> > > at
> >
> > org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321
> > )
> >
> > > > at
> >
> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSup
> > p
> >
> > > > ort.java:119) at
> >
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
> >
> > > at
> >
> > org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
> >
> > > at
> >
> > org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
> >
> > > at
> >
> > org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
> >
> > > at
> >
> > org.apache.catalina.core.StandardService.start(StandardService.java:519)
> >
> > > > at
> >
> > org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> >
> > > > at
> >
> > org.apache.catalina.startup.Catalina.start(Catalina.java:581)
> >
> > > > at
> > >
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> >
> > Method)
> >
> > > > at
> >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > > 39) at
> >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> > m
> >
> > > > pl.java:25) at
> > >
> > > java.lang.reflect.Method.invoke(Method.java:597)
> > >
> > > > at
> >
> > org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
> >
> > > > at
> >
> > org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
> >
> > > > Caused by: javax.xml.ws.WebServiceException:
> > > java.lang.NullPointerException
> > >
> > > > at
> >
> > org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:335)
> >
> > > > at
> >
> > org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:238)
> >
> > > > at
> >
> > org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:481)
> >
> > > > at
> > >
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> >
> > Method)
> >
> > > > at
> >
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> > > > 39) at
> >
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI
> > m
> >
> > > > pl.java:25) at
> > >
> > > java.lang.reflect.Method.invoke(Method.java:597)
> > >
> > > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
> >
> > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
> >
> > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> > o
> >
> >
> > ry.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
> >
> > > ... 36 more
> > >
> > > > Caused by: java.lang.NullPointerException
> > > > at
> >
> > org.apache.cxf.binding.soap.SoapTransportFactory.getDestination(SoapTrans
> > p
> >
> > > > ortFactory.java:123) at
> >
> > org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:92)
> >
> > > at
> >
> > org.apache.cxf.endpoint.ServerImpl.<init>(ServerImpl.java:71)
> >
> > > > at
> >
> > org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:1
> > 4
> >
> > > > 9) at
> >
> > org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean
> > .
> >
> > > > java:183) at
> >
> > org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:407)
> >
> > > at
> >
> > org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:314)
> >
> > > ... 45
> > >
> > > > more
> > > >
> > > > --- On Fri, 10/29/10, Daniel Kulp <[email protected]>
> > >
> > > wrote:
> > > > > From: Daniel Kulp <[email protected]>
> > > > > Subject: Re: Problem using LocalTransport
> >
> > in
> >
> > > Tomcat
> > >
> > > > > To: [email protected]
> > > > > Cc: "Joe Lin" <[email protected]>
> > > > > Date: Friday, October 29, 2010, 12:21 PM
> > > > > On Friday 29 October 2010 3:03:06 pm
> > > > >
> > > > > Joe Lin wrote:
> > > > > > Hi, I have two Jax-WS service endpoints
> >
> > that
> >
> > > I
> > >
> > > > > configure using the
> > > > >
> > > > > > CXFServlet transport as the following
> >
> > (in
> >
> > > beans.xml):
> > >
> > >
> > > =============================================
> > >
> > > > > > <jaxws:endpoint
> > > > >
> > > > > id="orderProcess"
> >
> > implementor="demo.order.OrderProcessImpl"
> >
> > > > > address="/OrderProcess" />
> > > > >
> > > > > > <jaxws:endpoint id="helloService"
> > > > >
> > > > > implementor="demo.order.HelloImpl"
> > > > >
> > > > > > address="/hello" />
> >
> > =============================================
> >
> > > > > > It all worked fine. And I'd like to
> >
> > have
> >
> > > another
> > >
> > > > > service that uses the
> > > > >
> > > > > > LocalTransport. So I copied the example
> >
> > from
> >
> > > the users
> > >
> > > > > guide in cxf
> > > > >
> > > > > > website.
> > >
> > > =============================================
> > >
> > > > > > <bean
> >
> > class="org.apache.cxf.transport.local.LocalTransportFactory"
> >
> > > > > > lazy-init="false"> <property
> > > > >
> > > > > name="transportIds">
> > > > >
> > > > > >
> > > > >
> > > > > <list>
> > > > >
> > > > > >
> > >
> > >
> > >
> > > > > <value>http://cxf.apache.org/transports/local</value>
> > > > >
> > > > > >
> > >
> > >
> > >
> > > > > <value>http://schemas.xmlsoap.org/soap/http</value>
> > > > >
> > > > > >
> > >
> > >
> > >
> > > > > <value>http://schemas.xmlsoap.org/wsdl/soap/http</value>
> > > > >
> > > > > Hmm... not sure why those last two URI's
> >
> > are
> >
> > > > > there. Don't do
> > >
> > > that. That
> > >
> > > > > will likely cause other issues as other
> >
> > things
> >
> > > will start
> > >
> > > > > using the local
> > > > > transport instead.
> > > > >
> > > > > BTW: you could just do:
> > > > > <import
> >
> > resource="classpath:META-INF/cxf/cxf-extension-local.xml"/>
> >
> > > > > instead.
> > > > >
> > > > > >
> > > > >
> > > > > </list>
> > > > >
> > > > > >
> > >
> > > </property>
> > >
> > > > > > </bean>
> > > > > >
> > > > > >
> > >
> > > <jaxws:endpoint
> > >
> > > > > id="helloLocal" address="local://hello"
> >
> > implementor="demo.order.HelloImpl2"/>
> >
> > > > > > <jaxws:endpoint
> > > > >
> > > > > id="orderProcess"
> >
> > implementor="demo.order.OrderProcessImpl"
> >
> > > > > address="/OrderProcess" />
> > > > >
> > > > > > <jaxws:endpoint id="helloService"
> > > > >
> > > > > implementor="demo.order.HelloImpl"
> > > > >
> > > > > > address="/hello" />
> > >
> > > =============================================
> > >
> > > > > > But I'm getting this in catalina.out:
> > > =============================================
> >
> > org.springframework.beans.factory.BeanCreationException:
> > > > > Error creating
> > > > >
> > > > > > bean with name 'helloLocal': Invocation
> >
> > of
> >
> > > init method
> > >
> > > > > failed; nested
> > > > >
> > > > > > exception is
> > >
> > > javax.xml.ws.WebServiceException:
> > > > > > java.lang.NullPointerException at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> >
> > > > > o
> >
> > ry.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
> >
> > > > > at
> >
> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFact
> >
> > > > > o
> >
> > ry.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
> >
> > > ===============================================
> > >
> > > > > Is there more to that stack trace?
> > >
> > > Normally
> > >
> > > > > there would be a "caused by"
> > > > > thing with more lines.
--
Daniel Kulp
[email protected]
http://dankulp.com/blog