Hi Jason,

Everything looks roughly correct. Can you paste the log output? You should
some output from this line of code:

LOG.info("Mapping method " + name + " to resource " + resource + " and verb
" + verb);

Which should help clarify whats going on...

- Dan

On 7/12/07, Jason Mihalick <[EMAIL PROTECTED]> wrote:

Hello,

For the life of me I can't seem to get a simple RESTful webservice to work
when I deploy it to Jetty (I haven't tried any other containers).  I
assume
that I am correct in using the CFXServlet to handle requests and route
them
to the service implementation?  iat-services is the name of my webapp
context.

When I try to do a GET on this URL (just using a web browser):
http://localhost:8080/iat-services/ws/

I get this output: {http://services.iat.jcol.com/}ClientServiceImplPort

That looks fine, I think.

Now, when I try to invoke my "client" service, with this url:
http://localhost:8080/iat-services/ws/client/10

I get this output: Invalid URL/Verb combination. Verb: GET Path: /10

If I try: http://localhost:8080/iat-services/ws/client/client/10

I get this output: Invalid URL/Verb combination. Verb: GET Path:
/client/10

What am I doing wrong here?  My classes and config are below.  I can post
a
stack trace if you think it will help.

==================
Service interface:
==================
package com.jcol.iat.services;

import java.util.Collection;

import javax.jws.WebService;

import org.codehaus.jra.Delete;
import org.codehaus.jra.Get;
import org.codehaus.jra.HttpResource;
import org.codehaus.jra.Post;
import org.codehaus.jra.Put;


@WebService
public interface ClientService {

  public Collection<Client> getClients();

  public Client getClient( long id );
  public void addClient( Client client );

  public void updateClient( long id, Client client);

  public void deleteClient( long id );

}


=============
Service Impl:
=============
package com.jcol.iat.services;

import java.util.ArrayList;
import java.util.Collection;

import javax.jws.WebService;

@WebService(endpointInterface = "com.jcol.iat.services.ClientService")
public class ClientServiceImpl implements ClientService {

  public ClientServiceImpl() {

  }

  public Collection<Client> getClients() {
    System.out.println( "getClients invoked" );
    return new ArrayList<Client>();
    // FIXME
  }

  public Client getClient( long id ) {
    System.out.println( "getClient invoked" );
    // FIXME
    return new Client();
  }

  public void addClient( Client client ) {
    System.out.println( "addClient invoked" );
    //FIXME
  }

  public void updateClient( long id, Client client) {
    System.out.println( "updateClient invoked" );
    //FIXME
  }

  public void deleteClient( long id ) {
    System.out.println( "deleteClient invoked" );
    //FIXME
  }

}

=========
beans.xml
=========
<beans xmlns="http://www.springframework.org/schema/beans";
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
             xmlns:jaxws="http://cxf.apache.org/jaxws";
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://cxf.apache.org/jaxws
file:///Applications/Java/toolkits/apache-cxf/apache-cxf-2.0-incubator-src
/rt/frontend/jaxws/src/main/resources/schemas/jaxws.xsd"
>
<!-- Fix the jaxws schemaLocation above -->

<!--

             xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                                 http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd";

    -->
        <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" />
        <import resource="classpath:META-INF/cxf/cxf-
extension-http-binding.xml" />

  <bean id="JaxWsServiceFactoryBean"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean">
    <property name="wrapped" value="false"/>
  </bean>

  <jaxws:endpoint id="restfulServer"
              implementor="com.jcol.iat.services.ClientServiceImpl"
              address="/client"
              bindingUri="http://apache.org/cxf/binding/http";>
     <jaxws:serviceFactory>
         <ref bean="JaxWsServiceFactoryBean"/>
     </jaxws:serviceFactory>
  </jaxws:endpoint>
</beans>

=======
web.xml
=======
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"; >

<web-app>
        <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>WEB-INF/beans.xml</param-value>
        </context-param>

        <listener>
                <listener-class>

org.springframework.web.context.ContextLoaderListener
                </listener-class>
        </listener>

        <servlet>
                <servlet-name>CXFServlet</servlet-name>
                <display-name>CXF Servlet</display-name>
                <servlet-class>
                        org.apache.cxf.transport.servlet.CXFServlet
                </servlet-class>
                <load-on-startup>1</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>CXFServlet</servlet-name>
                <url-pattern>/ws/*</url-pattern>
        </servlet-mapping>
</web-app>

Thanks,
Jason





--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Reply via email to