Hi John, Yes that was it! It worked fine.
It worked both with the wsdl file in the classpath and also with the wsdl in /WEB-INF/wsdl/ (with the property wsdlLocation="/WEB-INF/wsdl/TestWSDL.wsdl" and even with wsdlLocation="WEB-INF/wsdl/TestWSDL.wsdl") Thanks a lot for your help, Josef -----Original Message----- From: [email protected] [mailto:[email protected]] Sent: 22 January 2009 11:04 To: [email protected] Subject: RE: Problem with using Contract-first WSDL Hi Josef, Yes you are on the right track! Ok to specify the namespace in the endpoint definition, you will need to do something like: <jaxws:endpoint ... serviceName="s:GreetingService" xmlns:s="http://j2ee.netbeans.org/wsdl/TestWSDL"> Here the s: in the serviceName is important (you can use whatever identifier you like). Then I am assuming somewhere in you WSDL you have: <service name="GreetingService"> So as long as it can find the WSDL on the classpath it should be ok. Regards, John. Quoting Josef Bajada <[email protected]>: > Hi John, > > I tried to put TestWSDL.wsdl in the classpath and changed the > jaxws:endpoint to wsdlLocation="TestWSDL.wsdl" however I got the same > error "Could not find definition for service". > > Could it be I am doing something wrong in the serviceName or > endpointName? > > I noticed that the error is saying: > {http://www.springframework.org/schema/beans}GreetingService. > > Where did that www.springframework.org/schema/beans namespace come from? > In my case the namespace of the WSDL is > http://j2ee.netbeans.org/wsdl/TestWSDL. > > Could it be related? Should I declare the namespace somewhere and prefix > the serviceName and endpointName with its namespace identifier like tns: > ? > > Thanks, > > Josef > > > -----Original Message----- > From: [email protected] [mailto:[email protected]] > Sent: 22 January 2009 10:17 > To: [email protected] > Subject: Re: Problem with using Contract-first WSDL > > Hi Josef, > > I have taken the approach you are seeking of publishing a custom WSDL > many times. What I found was I need to place the .wsdl somewhere on > the classpath, normally I just use WEB-INF/classes, then link it > simply by the filename: > > ... > wsdlLocation="TestWSDL.wsdl" > ... > > Is the /WEB-INF/wsdl directory on the classpath? If so the above > should work fine. > > Regards, > > John. > > > Quoting Josef Bajada <[email protected]>: > >> I am trying to use CXF with Spring in Contract-first style. I wrote my >> WSDL file with various restrictions and refinements, generated the > Java >> classes with wsdl2java and implemented my web service. All worked > fine, >> however I noticed that the WSDL that is being generated is not my WSDL >> but the dynamically built WSDL which is generated from Java (which > omits >> all my specific restrictions etc. specified in the schema.) >> >> >> >> So I have put my WSDL file into /WEB-INF/wsdl/ and modified my > endpoint >> in the spring configuration as follows: >> >> >> >> <jaxws:endpoint >> >> id="greetingServiceEndpoint" >> >> implementor="#greetingService" >> >> wsdlLocation="/WEB-INF/wsdl/TestWSDL.wsdl" >> >> serviceName="GreetingService" >> >> endpointName="GreetingPort" >> >> address="/GreetingService"/> >> >> >> >> I have tried various variations of the above too, however none seems > to >> work. I am always getting the following exception. If I remove the >> wsdlLocation then everything works perfectly. How do I get Spring and >> CXF to expose my WSDL not their dynamically generated one? Am I doing >> something wrong or do I have something missing? >> >> >> >> Environment: Tomcat 6.0.18, Spring 2.5.5, Apache CXF 2.1.2 >> >> >> >> Thanks, >> >> >> >> Josef >> >> >> >> >> >> 22-Jan-2009 02:24:51 org.springframework.web.context.ContextLoader >> initWebApplicationContext >> >> SEVERE: Context initialization failed >> >> org.springframework.beans.factory.BeanCreationException: Error > creating >> bean with name 'greetingServiceEndpoint': Invocation of init method >> failed; nested exception is javax.xml.ws.WebServiceException: >> org.apache.cxf.service.factory.ServiceConstructionException: Could not >> find definition for service >> {http://www.springframework.org/schema/beans}GreetingService. >> >> Caused by: javax.xml.ws.WebServiceException: >> org.apache.cxf.service.factory.ServiceConstructionException: Could not >> find definition for service >> {http://www.springframework.org/schema/beans}GreetingService. >> >> at >> org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:267) >> >> at >> org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:201) >> >> at >> org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:394) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native >> Method) >> >> at >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav >> a:39) >> >> at >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor >> Impl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> >> at >> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac >> > tory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242 >> ) >> >> at >> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac >> tory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208) >> >> at >> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac >> tory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172) >> >> at >> > org.springframework.beans.factory.support.AbstractAutowireCapableBeanFac >> tory.createBean(AbstractAutowireCapableBeanFactory.java:427) >> >> at >> > org.springframework.beans.factory.support.AbstractBeanFactory$1.getObjec >> t(AbstractBeanFactory.java:249) >> >> at >> > org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.g >> etSingleton(DefaultSingletonBeanRegistry.java:155) >> >> at >> > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab >> stractBeanFactory.java:246) >> >> at >> > org.springframework.beans.factory.support.AbstractBeanFactory.getBean(Ab >> stractBeanFactory.java:160) >> >> at >> > org.springframework.beans.factory.support.DefaultListableBeanFactory.pre >> InstantiateSingletons(DefaultListableBeanFactory.java:291) >> >> at >> > org.springframework.context.support.AbstractApplicationContext.refresh(A >> bstractApplicationContext.java:352) >> >> at >> > org.springframework.web.context.ContextLoader.createWebApplicationContex >> t(ContextLoader.java:246) >> >> at >> > org.springframework.web.context.ContextLoader.initWebApplicationContext( >> ContextLoader.java:189) >> >> at >> > org.springframework.web.context.ContextLoaderListener.contextInitialized >> (ContextLoaderListener.java:49) >> >> at >> > org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j >> ava:3843) >> >> at >> > org.apache.catalina.core.StandardContext.start(StandardContext.java:4342 >> ) >> >> at >> > org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja >> va:791) >> >> at >> > org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) >> >> at >> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) >> >> at >> > org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java: >> 627) >> >> at >> > org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java >> :553) >> >> at >> org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488) >> >> at >> org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149) >> >> at >> > org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:31 >> 1) >> >> at >> > org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSu >> pport.java:117) >> >> at >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) >> >> at >> org.apache.catalina.core.StandardHost.start(StandardHost.java:719) >> >> at >> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) >> >> at >> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443) >> >> at >> > org.apache.catalina.core.StandardService.start(StandardService.java:516) >> >> at >> org.apache.catalina.core.StandardServer.start(StandardServer.java:710) >> >> at >> org.apache.catalina.startup.Catalina.start(Catalina.java:578) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native >> Method) >> >> at >> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav >> a:39) >> >> at >> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor >> Impl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> >> at >> org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) >> >> at >> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) >> >> Caused by: > org.apache.cxf.service.factory.ServiceConstructionException: >> Could not find definition for service >> {http://www.springframework.org/schema/beans}GreetingService. >> >> at >> > org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java: >> 114) >> >> at >> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildService >> FromWSDL(ReflectionServiceFactoryBean.java:309) >> >> at >> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeSe >> rviceModel(ReflectionServiceFactoryBean.java:403) >> >> at >> > org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(Refle >> ctionServiceFactoryBean.java:188) >> >> at >> > org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsService >> FactoryBean.java:164) >> >> at >> > org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint( >> AbstractWSDLBasedEndpointFactory.java:100) >> >> at >> > org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: >> 116) >> >> at >> > org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea >> n.java:168) >> >> at >> org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:336) >> >> at >> org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:251) >> >> ... 43 more >> >> 22-Jan-2009 02:24:51 org.apache.catalina.core.StandardContext start >> >> SEVERE: Error listenerStart >> >> > > >
