Hi, 

thanks for your help.

The code I was looking at was indeed the SpringServletTest, in
cxf-rt-frontend-jaxws.

I looked at the hello_world sample,
in /distribution/src/main/release/samples/hello_world, but it doesn't
look like it contains a complete example of a war (with the web.xml,
complete implementation, etc..).

All I find is a Server.java file that registers a service using the
Endpoint API. 

=> So, I tried keeping the same setup, but publishing my service using
the Endpoint API (Endpoint.publish(), while keeping my servlet, and
everything... But still.. When I browse /<war>/cxf/, CXF tells me there
is no service available..... Isn't it supposed to list all services
available on the Bus, no matter what their address are, anyways ?


So, I guess there is some kind of basic concept I didn't grasp
correctly.. I repeat that I got to work the example from the blog, and
the only thing I need on top of that is to call the service from a
Servlet, instead of an embedded web server....

Thanks for your help,
Sami Dalouche


Le dimanche 04 février 2007 à 03:46 -0500, Jiang, Ning a écrit :
> 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.
> 
> 

Reply via email to