Hi Sami, Before I answer your question , I had to ask you some questions.
Where do you run the test code? In the cxf-rt-frontend-jaxws project or the servlet container. In the cxf-rt-frontend-jaxws project we use httpunit for test :). You can't get the webservice from the browser. Please see my comments in the mail. -----Original Message----- From: Sami Dalouche [mailto:[EMAIL PROTECTED] Sent: 2/4/2007 3:30 To: [email protected] Subject: CXF, Spring, CXFServlet 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 ? If you follow the SpringServletUnitTest, please follow its test code to test the service. => Do you see anything wrong here ? Do you have any suggestion ? First you need to deploy the war to the servlet container , you can find the instruction from the hello_world sample which distributed with CXF kit. You need make sure the address match the servlet url-pattern which you deploied the war. You can test the service which you publish by using this url http://localhost/{war_name}/cxf/ => What's the meaning of the "address" property ? why do I have to give the port/ address again, and not just some relative path ? Actually the CXF service publish API don't know anything about the CXF Servlet, so you need to set up the "address" property for publish service by code or spring file. In the CXFServlet , we support get the endpoint info from cxf-servlet.xml, it publish the endpoint with the relative path. Thanks for your help, Sami Dalouche Cheers, Willem.
