Hi

That must work, which CXF version do you use ?

I've added a test locally and it just works, see the diff below as this has to be already tested on the trunk, so I'm not merging it at the moment.

Try please 2.3.7/2.4.3

thanks, Sergey


Index: src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
===================================================================
--- src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (revision 1182563) +++ src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (working copy)
@@ -950,6 +950,20 @@
     }

     @Test
+    public void testGetBook222() throws Exception {
+ WebClient wc = WebClient.create("http://localhost:"; + PORT + "/bookstore/books/222");
+        Book book = wc.get(Book.class);
+        assertEquals(222L, book.getId());
+    }
+
+    @Test
+    public void testGetBook333() throws Exception {
+ WebClient wc = WebClient.create("http://localhost:"; + PORT + "/bookstore/books/333");
+        Book book = wc.get(Book.class);
+        assertEquals(333L, book.getId());
+    }
+
+    @Test
     public void testGetBook123() throws Exception {
getAndCompareAsStrings("http://localhost:"; + PORT + "/bookstore/books/123",
                                "resources/expected_get_book123.txt",
Index: src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
===================================================================
--- src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (revision 1176840)
+++ src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java   (working copy)
@@ -477,12 +477,25 @@
     }

     @GET
+    @Path("/books/222")
+    @Produces("application/xml")
+ public Book getBook222(@PathParam("bookId") String id) throws BookNotFoundFault {
+        return new Book("222", 222);
+    }
+
+    @GET
     @Path("/books/{bookId}/")
     @Produces("application/xml")
public Book getBook(@PathParam("bookId") String id) throws BookNotFoundFault {
         return doGetBook(id);
     }

+    @GET
+    @Path("/books/333")
+    @Produces("application/xml")
+ public Book getBook333(@PathParam("bookId") String id) throws BookNotFoundFault {
+        return new Book("333", 333);
+    }


     @GET

On 12/10/11 19:19, Romain Manni-Bucau wrote:
Hi,

i wonder if it is normal (which i don't think if i write this mail) or not:

why cxf is taken the first method matching a uri pattern when a rest service
is called?

as an example is clearer than any speech:

why these patterns are not guarantee to work:

/foo/{id} # id = Long for instance
/foo/bar

as the first one will match the second one the result will depend on the
order of declaration and if the second takes the first one an error will
appear, something like bar cannot be converted to Long.

- Romain


Reply via email to