I’m dabbling in web services setup, not really knowing what I’m doing yet, and here’s a situation I encountered today:
I was taking a prior example where the web service setup had been done for me, and adapting it for use with a new prototype. I had a WEB-INF/services.xml that looked like this:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:amq="http://activemq.org/config/1.0" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:http-conf="http://cxf.apache.org/transports/http/configuration" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://activemq.org/config/1.0 http://activemq.apache.org/schema/core/activemq-core-5.0.0.xsd" default-autowire="no"> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <jaxws:endpoint id="myGreetingSvcEndpoint" implementor="#myGreetingSvc" address="/GreetingSvc" /> <bean id="greetingSvc" class="com.example.svc.GreetingSvcImpl"> <property name="messageSender" ref="messageSender" /> </bean> </beans>
When I tried deploying this though, it was looking for a myGreetingSvc bean and couldn’t find it:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myGreetingSvcEndpoint': Cannot resolve reference to bean 'myGreetingSvc' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myGreetingSvc' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java ... Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'myGreetingSvc' is defined
Why would it be looking for a myGreetingSvc bean? It seems that the implementor attribute of the jaxws:endpoint expects to reference a bean — replacing “#myGreetingSvc” with “#greetingSvc” on line 14 in services.xml (and correcting my @WebService annotation’s endpointInterface property in GreetingSvcImpl.java to match the name of the interface it was trying to point to) got it working.
I think a lot of how our service.xml is set up (how it’s Spring-like) is because we’re also using CXF, which I hear is Spring-aware. There’s a lot I still don’t know about web services!