In my project, we are not using Spring. Is it possible to use Apache Camel and Apache CXF to build REST service?
I used
<listener>
<listener-class>
org.apache.camel.component.servletlistener.SimpleCamelServletContextListener
</listener-class>
</listener>
<servlet-class>
org.apache.camel.component.servlet.CamelHttpTransportServlet
</servlet-class>
I create a Route class, and I am able to utilize that route. But, this doesn't look like REST service, but looks like plain Servlet call.
How to use CXF here to build REST service.
It's hard to config the CXF REST endpoint without using Spring.
I think you can use simple binding to build the route.
Another option you could consider apart from the one Willem suggested is using Restlet. Apache Camel provides a nice integration with the framework and super-easy usage.
You can find more info about Restlet and its Apache Camel integration here
I have an example at:
http://code.notsoclever.cc/camel-cxfrs-jdbc-rest-example/
The example does use Spring but note that the CXFRS component is not configured in Spring.
Related
I have one Eclipse RCP3 project.Now I need to call a rest api|(java) and Post some information using that API. Need Help.
Being a Java application, an Eclipse RCP app can use most existing Java REST client libraries. My opinion is that the easiest way is to use the ECF JAX-RS Jersey Client. I recently wrote an article about how to incorporate this into an Eclipse RCP application:
https://www.modumind.com/2020/05/19/eclipse-rcp-and-rest-an-introduction/
In short, the JAX-RS Jersey Client is an OSGi Remote Services client created as part of the Eclipse Communications Framework (ECF) project. It embeds a Jersey/Jackson JAX-RS implementation that allows you to create REST clients as annotated interfaces that are made available as OSGi services locally. Jackson is used to data bind the REST responses to Java POJOs which require little or no annotation.
This solution allows you to skip most of the scaffolding code that usually has to be written to make REST calls in a Java application. But of course, you can also use Jersey and Jackson directly, those plugins are made available via Eclipse Orbit project.
http://www.eclipse.org/orbit
The GitHub repository for the ECF JAX-RS Jersey Client can be found here:
https://github.com/ECF/JaxRSProviders
I am new to Webservices, I am confused about the JAX-RS and apache CXF
What i read is that JAX-RS is API and Apache CXF is implementation of JAX-RS
JAX-RS is not specification , Is it possible to direclty use JAX-RS to build REST services?
Please correct me if I am wrong
Regards
JAX-RS is a specification. The binaries provided by it only contain Interface definitions but no implementations.
The default implementation of JAX-RS is Jersey. It provides implementations plus additional features.
Apache CXF and Restlet are other implementations of JAX-RS that provide different additional features.
I have an OFBiz SOAP-based web service that is exposed (can accept requests) and has a WSDL code generated and a WSDL URL. My Question is, is there a way to consume this web service using a CXF Java client or JAX-WS client?
Overall, i want to be able to add the client in the Mule esb consigeration as part of a Mule FLOW. I can invoke the OFBiz web service using AXIS2, but Mule ESB does not seem to support AXIS2, which brings me to another question - Is there a way i can configure AXIS2 web service client in Mule ESB?
Thanks in Advance
Follow the WSDL-first approach from the Consuming Web Services user guide.
This involves:
generating a CXF client using the WSDL to Java tool from CXF or the Maven plugin,
configuring the client as an outbound endpoint.
And leads to a Mule configuration that looks like:
<cxf:jaxws-client
clientClass="org.apache.hello_world_soap_http.SOAPService"
wsdlPort="SoapPort"
wsdlLocation="classpath:/wsdl/hello_world.wsdl"
operation="greetMe"/>
<outbound-endpoint address="http://localhost:63081/services/greeter"/>
I have implemented a RESTful web service using jersey and deployed it on Tomcat, I have used DAO classes to manipulate database operations, entities to wrap database records. and did the processing in separate package. I want to make this system distributed using EJB. First of all would it be easy to do this change. or i need to rewrite things from scratch. Second, I still need to have the REST WS, so would it be possible to expose the EJB as a REST WS and how? would the REST WS be in the same EJB project or in a different one?
You can definitely do it as an EJB and REST WS. Upgrade your Tomcat install to TomEE Plus, then just add #Stateless or #Singleton to the existing REST service.
You won't need Jersey in there anymore as the Java EE version of Tomcat (TomEE) includes CXF for JAX-RS support.
This example is not well documented, but shows a functional application that combines both EJB and JAX-RS.
http://tomee.apache.org/examples-trunk/rest-on-ejb/README.html
I want to create client-side java from a restful web service, so that I can call the service. Do somebody know if CXF provide such this tools?
Best,
With CXF 2.4.1, CXF does provide a "wadl2java" tool that can be used to create a Java client from a WADL document. If your restful service provides a WADL, that can be used as a starting point.