You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by blacar <bc...@gmail.com> on 2014/02/03 16:13:40 UTC

Programatically publishing a RESTful service

Hi,

I am used to declare REST services on the XML file in order to publish ...
something like 

<jaxrs:server id="customerService" address="/">
  <jaxrs:serviceBeans>
    <bean class="org.apache.cxf.jaxrs.systests.CustomerService" />
  </jaxrs:serviceBeans>
</jaxrs:server>

Is there a way to publish them programmatically ... like SOAP Webservices:

Endpoint.publish(URL, serviceBean) 

?

Thxs,



--
View this message in context: http://cxf.547215.n5.nabble.com/Programatically-publishing-a-RESTful-service-tp5739401.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Programatically publishing a RESTful service

Posted by Alex O'Ree <sp...@gmail.com>.
Yup there you go. I was going to link you to this example:
http://svn.apache.org/repos/asf/juddi/trunk/juddi-rest-cxf/src/test/java/org/apache/juddi/api/impl/rest/UDDIInquiryJAXRSTest.java

Specifically, the "startServer" method, which fires up endpoints for
json and xml programmatically in a junit test

On Mon, Feb 3, 2014 at 10:29 AM, blacar <bc...@gmail.com> wrote:
> Googling a bit more i've found this:
>
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> sf.setResourceClasses(CustomerService.class);
> sf.setAddress("http://localhost:9000/");
> sf.create();
> A couple of things to note:
>
> The JAXRSServerFactoryBean creates a Server inside CXF which starts
> listening for requests on the URL specified.
>
> JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
> CustomerService cs = new CustomerService();
> sf.setServiceBeans(cs);
> sf.setAddress("http://localhost:9080/");
> sf.create();
>
>
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Programatically-publishing-a-RESTful-service-tp5739401p5739411.html
> Sent from the cxf-user mailing list archive at Nabble.com.

Re: Programatically publishing a RESTful service

Posted by blacar <bc...@gmail.com>.
Googling a bit more i've found this:

JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
sf.setResourceClasses(CustomerService.class);
sf.setAddress("http://localhost:9000/");
sf.create();
A couple of things to note:

The JAXRSServerFactoryBean creates a Server inside CXF which starts
listening for requests on the URL specified.

JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
CustomerService cs = new CustomerService();
sf.setServiceBeans(cs);
sf.setAddress("http://localhost:9080/");
sf.create();






--
View this message in context: http://cxf.547215.n5.nabble.com/Programatically-publishing-a-RESTful-service-tp5739401p5739411.html
Sent from the cxf-user mailing list archive at Nabble.com.