2010/11/10 Sergey Beryozkin <[email protected]> > Hi > > I'm a bit confused, obviously "http://mypc:9000/api/service?_wadl" was > just > an example you gave me... >
Yes that was an example. But it says that /services give you a list of all available webservices in WADL format. For a start, the fact that "http://mypc:9000?_wadl" is not giving you a wadl > instance describing all the root resources is a bug most likely to do with > the fact the embedded Jetty is used - I'll verify. You may actually want to > try "http://mypc:9000/?_wadl", note the trailing forward slash. I've fixed > an http-transport level bug a couple of days ago to do with some ambiguity > in cases with trailing forward slashes, only exposed when certain address > combinations were used. > Same result with the slash > > Now, I'm not exactly sure about say > > /catalog/CatalogService (class-level: "/api/v1.0/catalog", function-level: > "/{id}" and "/{id}/delete" and "/{id}/add") > > what is "/catalog/CatalogService" ? it appears that all the root resources > start from "/api/" ? > It is much simpler to understand what is going on when a sample resource > class with relevant bits is posted... > Ok, here is a bit of code // // Class VersionService // package com.foo.bar.api; @Path("/api/versions") public class VersionService { @GET @Path("/") @Produces(MediaType.TEXT_XML) public JAXBElement<SupportedVersionsType> getVersions() { ObjectFactory myFactory = new ObjectFactory(); ... return myFactory.createSupportedVersions(supportedVersions); } } // // Class LoginService // package com.foo.bar.login; @Path("/api/v1.0/login") public class LoginService { @POST @Path("/") @Produces("application/vnd.foo.bar.login+xml") public JAXBElement<ListType> login() { ObjectFactory myFactory = new ObjectFactory(); ... return myFactory.createOrgList(list); } } // // Class CatalogService // package com.foo.bar.catalog; @Path("/api/v1.0/catalog/") public class CatalogService { @GET @Path("/{id}") @Produces("application/vnd.foo.bar.catalog+xml") public JAXBElement<CatalogType> getContent(@PathParam("id") String id) { ObjectFactory myFactory = new ObjectFactory(); ... return myFactory.createCatalog(cat); } @POST @Path("/{id}/action/upload") @Consumes("application/vnd.foo.bar.uploadParams+xml") @Produces("application/vnd.foo.bar.catalog+xml") public JAXBElement<CatalogType> upload(@PathParam("id") String id, UploadParamsType params) { ObjectFactory myFactory = new ObjectFactory(); ... return myFactory.createCatalog(catType); } @POST @Path("/{id}/media") @Consumes("application/vnd.foo.bar.media+xml") @Produces("application/vnd.foo.bar.media+xml") public JAXBElement<MediaType> uploadMediaImage(@PathParam("id") String id, MediaType mediaParam) { ObjectFactory myFactory = new ObjectFactory(); ... return myFactory.createMedia(mediaType); } } The API is given, I cannot change it. Is the package organisation a problem? Or the "/api" prefix? > Besides that, the only I can comment about is that unless you have to use > POST to indicate the deletions and additions (ex, it is not easy to specify > DELETE on the client side) then you may want to remove /delete and /add > bits > and use @DELETE and @POST : > > @GET > @PATH("{id}") > SomeBean get(...) {} > > > @POST > @PATH("{id}") > void add(...) {} > > @DELETE > @PATH("{id}") > void delete(...) {} > > also note you use a ?_method=DELETE if no explicit DELETE verb can be set > on > the client side > > cheers, Sergey > > On Wed, Nov 10, 2010 at 11:21 AM, Jérôme Herry <[email protected]> wrote: > > > No, I do sf.setAddress("http://mypc:9000"); > > Here is what I have, maybe it's not the good way: > > /api/VersionService (class-level: "/api/versions", function-level: "/") > > /login/LoginService (class-level: "/api/v1.0/login", function-level: "/") > > /catalog/CatalogService (class-level: "/api/v1.0/catalog", > function-level: > > "/{id}" and "/{id}/delete" and "/{id}/add") > > > > What do you think? > > > > 2010/11/10 Sergey Beryozkin <[email protected]> > > > > > Were is "/api/" coming from, is it actually > > > > > > sf.setAddress("http://mypc:9000/api"); > > > > > > that you do ? > > > > > > And one of the root resources has a class-level @Path with the value > > > "/myservice" ? > > > > > > Given the code you shown it appears you have a single endpoint with two > > > root > > > resource classes (VersionService and LoginService) as opposed to two > > > endpoints... > > > > > > "http://mypc:9000/api?_wadl" should give you a WADL with both root > > > resources > > > described. > > > > > > I definitely have a test case confirming it is the case ()with slightly > > > different addresses), but may be in this case, with no servlet > transport > > > being involved, this does not work as expected...I'll have to verify > > > > > > cheers, Sergey > > > > > > > > > On Wed, Nov 10, 2010 at 10:19 AM, Jérôme Herry <[email protected]> > > wrote: > > > > > > > I already tried but I also have a 404. It works if I do it on an > > > endpoint, > > > > e.g. http://mypc:9000/api/myservice?_wadl > > > > but I would like to have a WADL with all available services. > > > > Maybe I have to add a provider but I don't know how and which one. > > > > > > > > 2010/11/10 Sergey Beryozkin <[email protected]> > > > > > > > > > Hi > > > > > > > > > > I think in this case the servlet transport is bypassed and no > handler > > > is > > > > > available for "/services". > > > > > "http://mypc:9000/?_wadl" should do it in this case. > > > > > > > > > > cheers, Sergey > > > > > > > > > > On Wed, Nov 10, 2010 at 10:00 AM, Jérôme Herry <[email protected] > > > > > > wrote: > > > > > > > > > > > Hi, I'm using CXF running a jetty server like this: > > > > > > > > > > > > JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); > > > > > > List rps = new Vector(); > > > > > > rps.add(new SingletonResourceProvider(new > VersionService())); > > > > > > rps.add(new SingletonResourceProvider(new LoginService())); > > > > > > ... > > > > > > sf.setResourceProviders(rps); > > > > > > > > > > > > List schemas = new ArrayList(); > > > > > > schemas.add("classpath:/versioning/versions.xsd"); > > > > > > ... > > > > > > sf.setSchemaLocations(schemas); > > > > > > > > > > > > sf.setAddress("http://mypc:9000"); > > > > > > > > > > > > sf.getInInterceptors().add(AuthenticationInterceptor.getInstance()); > > > > > > sf.getOutInterceptors().add(OutInterceptor.getInstance()); > > > > > > > > > > > > sf.setStaticSubresourceResolution(true); > > > > > > sf.create(); > > > > > > > > > > > > When I go to http://mypc:9000/services I have a 404 error. I > would > > > > like > > > > > to > > > > > > have the WADL with all my REST services. How can I do it? > > > > > > > > > > > > > > > > > > > > >
