Hi
On 03/06/13 16:32, eanbiso wrote:
Hi all,
I'm trying to publish and use cxf rest endPoint adding annotations required
to use the framework com.wordnik.swagger
I tried to follow the example at
https://github.com/wordnik/swagger-core/tree/master/samples/java-jaxrs-cxf/src/main/java/com/wordnik/swagger/sample
with some differences: I must publish the endPoint directly from java code.
My situatios is the following...

I have an endPoint with a simple interface like this:

     @WebService(targetNamespace = http://com.prova.pubdocs/)
     public interface IPublic extends IPublishable{
                
         @GET
        @Path("/isReady")
        @ApiOperation(value = "Check the instance is ready or not", notes =
"Returns a boolean corresponding to the instance state.", responseClass =
"boolean")
        boolean isReady();

     }
(the interface IPublishable specifies only the methods to publish and
unpublish the endPoints),       

and an implementor like this:
     @WebService("RestServicePubDocs", "PubDocs")
     public class RestPublicDocs implements IPublic, IPlat1Service {

        @Override
        public boolean isReady() {
                return true;
        }
     ....
     }

Following the example I've also  daclared the class:

     @Path("/PubDocs.json")
     @Api(value = "/PubDocs", description = "Operations about pubDocs")
     @Produces({"application/json"})
     public class RestPublicDocsJSON extends RestPublicDocs{}

and then I've published the end point in a similar way:

        private Server publishRestServerSwagger(String addr,
                        List<Interceptor&lt;? extends Message>> inInterceptors,
                        List<Interceptor&lt;? extends Message>> 
outInterceptors){
                Server simpl=null;
                try {   
                        JAXRSServerFactoryBean sf = new 
JAXRSServerFactoryBean();
                        sf.setServiceBean(new RestPublicDocsJSON()); //the 
implementor
                        sf.setServiceBean(new ApiListingResourceJSON()); 
//required from swagger
                        sf.setAddress(addr);
                        sf.setProvider(new JacksonJsonProvider()); //required 
from swagger
                        sf.setProvider(new RestExceptionHandler()); //my 
exception mapper
                        
                        if (inInterceptors != null) {
                                for (Interceptor<? extends Message> interceptor 
: inInterceptors) {
                                        sf.getInInterceptors().add(interceptor);
                                }
                        }
                        if (outInterceptors != null) {
                                for (Interceptor<? extends Message> interceptor 
: outInterceptors) {
                                        
sf.getOutInterceptors().add(interceptor);
                                }
                        }
                        
                        //add new rest fault interceptor
                        sf.getOutFaultInterceptors().add(new 
RestFaultInterceptor());
                        //new management end
                        simpl = sf.create();
                        //disable honorKeepAlive value depending on VMArg 
(honorKeepAlive default
value is true)
                        log.info("Endpoint has been published on " + addr);
                } catch (Exception e) {
                        log.warn("Error publishing endpoint: " + e.toString(), 
e);
                }
                
                return simpl;
        }


The publication seems to be successful and no exception occurs but when I
call the ws, a javax.ws.rs.WebApplicationException with status 404 and all
values null occurs.
If I remove the annotations from the RestPublicDocsJSON class the api works
properly and no exception occurs.
Someone can help me?
I can't see what may be going wrong from the code above.
In this fragment,

>      @Path("/PubDocs.json")
>      @Api(value = "/PubDocs", description = "Operations about pubDocs")
>      @Produces({"application/json"})
>      public class RestPublicDocsJSON extends RestPublicDocs{}

which annotations affect the api working properly ? Are these annotations the only ones on RestPublicDocsJSON ?

Sergey


Thanks a lot,

Andrea



--
View this message in context: 
http://cxf.547215.n5.nabble.com/CXF-and-swagger-tp5728644.html
Sent from the cxf-user mailing list archive at Nabble.com.


Reply via email to