Ok, fixed now. What I should have had was :

@Path(value="/{user}/mail")
public class MailService {

       @Path(value="", limited=true)
       @GET
       @ConsumeMime("application/xml")
       @ProduceMime("application/xml")
       public String listMail(@PathParam("user")String user){
               ...
       }

       @Path(value="{messageId}")
       @GET
       @ConsumeMime("application/xml")
       @ProduceMime("application/xml")
       public String readMessage(@PathParam("messageId")String messageId){
               ...
       }
}

Thanks for the pointer Sergey.

On Mon, Apr 28, 2008 at 1:43 PM, Brad <[EMAIL PROTECTED]> wrote:
> Hi Sergey,
>
>  I'm also trying to get this to work, so I was glad to see your email.
>  I tried the annotations you suggested:
>
>  @Path(value="/{user}/mail")
>  public class MailService {
>
>         @GET
>         @ConsumeMime("application/xml")
>         @ProduceMime("application/xml")
>         public String listMail(@PathParam("user")String user){
>                 ...
>         }
>
>         @Path(value="{messageId}")
>         @GET
>         @ConsumeMime("application/xml")
>         @ProduceMime("application/xml")
>         public String readMessage(@PathParam("messageId")String messageId){
>                 ...
>         }
>  }
>
>  I test it by going to http://localhost:8080/cxf/rest/test/user/mail.
>  It always ignores listMail and instead does readMessage with a null
>  messageId.
>
>  If I comment out readMessage it will invoke listMail.
>
>  Any tips?
>
>  Thanks,
>  Brad.
>
>
>
>  On Mon, Apr 28, 2008 at 10:24 AM, Sergey Beryozkin
>  <[EMAIL PROTECTED]> wrote:
>  > Thanks...
>  >
>  >  The problem is actually with these Path annotations :
>  >
>  >
>  >  >> @Path("/users/")
>  >  >> public class UserService {
>  >  >>
>  >  >>   @Path("/users/{id}/")
>  >  >>   public User getUser(@PathParam("id") String id) {
>  >  >>     ... // load from db
>  >  >>   }
>  >  >>
>  >  >>   ...
>  >  >>
>  >  >> }
>  >
>  >  it should be
>  >
>  >
>  >  @Path("/users/")
>  >  public class UserService {
>  >
>  >    @Path("{id}")
>  >
>  >    public User getUser(@PathParam("id") String id) {
>  >      ... // load from db
>  >    }
>  >
>  >  }
>  >
>  >  The Path annotations on the root resource class are 'inherited' and 
> concatenated with the one on the resource method getUser()...
>  >
>  >  For example to get a collection of users one can do
>  >
>  >
>  >  @Path("/users/")
>  >  public class UserService {
>  >
>  >    @GET
>  >    public Users getUsers() {
>  >        ...
>  >    }
>  >
>  >    @Path("{id}")
>  >
>  >    public User getUser(@PathParam("id") String id) {
>  >      ... // load from db
>  >    }
>  >
>  >  }
>  >
>  >  Cheers, Sergey
>  >
>  >
>  >
>  >  ----- Original Message -----
>  >  From: "Joshua Purcell" <[EMAIL PROTECTED]>
>  >  To: <[email protected]>
>  >  Sent: Monday, April 28, 2008 5:26 AM
>  >  Subject: Re: Question about JAX-RS Sub resources
>  >
>  >
>  >  >
>  >  > Your example is a little different from the sample JAX-RS code included 
> with
>  >  > the CXF snapshot. This may work better for you:
>  >  > @Path("/userservice/")
>  >  > public class UserService {
>  >  >  @Path("/users/{id}/")
>  >  >  public User getUser(@PathParam("id") String id) {
>  >  >    ... // load from db
>  >  >  }
>  >  > }
>  >
>  >  ----------------------------
>  >  IONA Technologies PLC (registered in Ireland)
>  >  Registered Number: 171387
>  >  Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
>  >
>

Reply via email to