Hi,
I am currently trying to get a JSON/REST service to work...
The example available on
http://netzooid.com/blog/2006/11/12/jsonrest-services-with-cxf-and-jettison/
works fine for me.
However, I would like
1] To use a Servlet instead of some HttpBindingInfoFactoryBean. I want
to embed CXF inside a Web Container, so I don't need/want a new port to
be opened to receive REST requests
2] To use Spring Configuration instead of programmatic Configuration.
So, I looked at CXF source code and it looks like there are some Spring
related classes, and CXFServlet.. I followed the same approach taken by
the SpringServletTest unit test, but no matter what I do, when I point
my browser to the cxf servlet, I get the following error message :
"No service was found."
@XmlRootElement(name="helloTextMessage")
public class Hello {
private String message = "testMessage";
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
@WebService(targetNamespace="http://acme.com")
public interface IHelloWorldService {
@Get
@HttpResource(location = "/hello")
@WebResult(name="helloMessage")
public abstract Hello getHello();
}
@WebService(endpointInterface =
"funala.web.services.IHelloWorldService")
public class HelloWorldImpl implements IHelloWorldService {
/* (non-Javadoc)
* @see funala.web.services.IHelloWorldService#sayHello()
*/
public Hello getHello() {
// return "<test><ok>this is a test </ok></test>";
return new Hello();
}
}
and my web.xml contains :
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/spring/*.xml</param-value>
</context-param>
<!-- CXF Servlet -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>org.apache.cxf.jaxws.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/cxf/*</url-pattern>
</servlet-mapping>
and one of the spring files that is source, contains :
<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"/>
<bean name="helloWorldImpl"
class="funala.web.services.HelloWorldImpl"></bean>
<bean name="helloWorldJaxWs"
factory-method="create"
factory-bean="helloWorldServerFactory"
class="org.apache.cxf.endpoint.Server" />
<bean id="helloWorldServerFactory"
class="org.apache.cxf.jaxws.JaxWsServerFactoryBean">
<property name="serviceClass"
value="funala.web.services.IHelloWorldService" />
<property name="bus" ref="cxf"/>
<property name="serviceFactory.invoker">
<bean class="org.apache.cxf.service.invoker.BeanInvoker">
<constructor-arg>
<ref bean="helloWorldImpl" />
</constructor-arg>
</bean>
</property>
<property name="address"
value="http://localhost:9090/funala/cxf/hello"/>
</bean>
=> I am trying to reach http://localhost:9090/funala/cxf/hello,
http://localhost:9090/funala/cxf/hello/hello, ... nothing works.. What
is the good url supposed to be ?
=> Do you see anything wrong here ? Do you have any suggestion ?
=> What's the meaning of the "address" property ? why do I have to give
the port/ address again, and not just some relative path ?
Thanks for your help,
Sami Dalouche