Amdatu Web using Jersey - java

Amdatu web uses apache wink to create restful web app in OSGi. Recently the Apache Wink project retired - I don't know exactly why.
My question is: Can I use apache web for my production OSGi application? is the RETIRED apache wink with in amdatu web stable for production usage? and If not how to use other rest providers like Jersey?
Thanks

In the next Amdatu Web release of Apache Wink will be replaced by RESTEasy, you can't just drop in any provider so it won't be possible to use Jersey.
Furthermore we are updating the whiteboard implementation in Amdatu Web to implement the JAX-RS Whiteboard specification mentioned by Neil Bartlett.

Related

How to call a JSON Rest web service with Tomee 1.6

My application is running on a Tomee plus 1.6 JEE server.
I need to call a RS WS that will return an object formatted as a JSon string.
I can do that with an openConnection("url"), and a manual parsing of the response. But I think there is a much higher way to do that in a JEE environment.
The problem is that I found many tutorials about how to write a Restful WS, but very few about how to invoke them. Moreover, eachtime, there are several libraries to add to the Tomee server (Jackson, ...).
My questions are :
is there any standard way to invoque a WS with no library to add ? I think there must be one because Tomee plus is supposed to be a full JEE server.
how to do that ?
Thanks for your help.
If you are not on tomee 7 but still tomee 1 you can use CXF WebClient to do that. TomEE 7 would let you use standard JAX-RS 2 client (part of EE 7) but was not in TomEE 1 (EE 6)
There are plenty of options to consume REST applications in Java nowadays. The current standard is the JAX-RS Client API, released in JAX-RS 2.0, and it's part of the Java EE 7 API.
Important: Once your are using Apache TomEE 1.6.0, which is Java EE 6 certified, the JAX-RS Client API won't be available for you. Keep reading.
JAX-RS Client API
The JAX-RS Client API (javax.ws.rs.client package), defined in the JSR 339 and released as part of the Java EE 7 API, is the standard way to consume REST web services in Java. Besides others, this specification is implemented by Jersey, RESTEasy and Apache CXF.
Vendor specific proxy frameworks
Both Jersey, RESTEasy and Apache CXF also provide a proxy framework API. Those APIs are vendor specific and are not part of the JAX-RS Client API.
The basic idea is you can attach the standard JAX-RS annotations to an interface, and then implement that interface by a resource class on the server side while reusing the same interface on the client side by dynamically generating an implementation of that using java.lang.reflect.Proxy calling the right low-level client API methods.
For more details check the following:
Jersey proxy-based client API
RESTEasy proxy-based client API
Apache CXF proxy-based client API
Other resources
Here are some other options that you could consider as alternative to the JAX-RS Client API:
Apache CXF WebClient API †
Spring RestTemplate
OkHttp
Retrofit
Netflix Feign
† Apache CXF WebClient API: It's shipped with the Apache TomEE 1.6.0. In the cxf-rt-frontend-jaxrs.jar you are going to find the WebClient class, which is the entry point to the client API.
Thank you very much for your help.
Finally, I decided to use the standard JAX-RS API, but as it was not released yet in Tomee 1.6, I had to add a jar file in the lib directory of the server :
javax.json-1.0.4.jar, which I downloaded from Oracle web site.
To compile my project, I had to use an other jar file : javax.json-api-1.0.4.jar
Since you have mentioned that you are using TomEE plus 1.6, you already have JAX-RS client (Ref: Apache TomEE) which can be used to access REST WS.
The javax.ws.rs.client can be used to invoke the REST service and receive the response. More detailed tutorial can be found on Oracle Site.
EDIT: Missed the version number part. The API is available in 1.7.

Is it possible to configure a Java web app to run with Apache Wink Server and JAX-RS 2.0?

I switched my application from using a Jersey Server to using an Apache Wink Server. Now, when I make CRUD operations to my API, I get the following error:
javax.servlet.ServletException: java.lang.AbstractMethodError: javax.ws.rs.core.Response.getStatusInfo()
I am sure this is happening because my application requires the use of JAX-RS 2.0, but Apache Wink is only JAX-RS 1.1 compliant.
I know that Apache CFX is JAX-RS 2.0 compliant, but I need to use Apache Wink to make the server responses align with a Liberty server (which uses Apache Wink).
So, is it possible to get Apache Wink + JAX-RS 2.0 working together on the same Java web app? And if so, please help me!

How to decide on what framework to use in Java Web Service?(SOAP)

I am fairly new in Java EE web service. Right now we have a project to create an API web service that connects to a database and do some retrieve and write functions.
I've heard about the following:
Axis
Struts
Spring
Can someone please enlighten me as to what framework is applicable for the said project? I've tried Google of course but I need opinion on people who have experience on the said framework.
BTW we are going to create a SOAP web service. Additional tips are also appreciated.
Note that Java has the JAX-WS API which is a technology for building web services and clients that communicate using XML. In JAX-WS, a web service operation invocation is represented by an XML-based protocol, such as SOAP.
From the frameworks you mentioned, Spring brings SpringWS which you can use to build a SOAP web service.
However i don't know about Struts 2 core api offering any SOAP capabilities.
But it can be extend with other plugins that handle SOAP.
Axis (use the latest, Axis 2) is a good choice for SOAP. It is a Web Services / SOAP / WSDL engine. It also has some support for the Spring Framework.
There is also Apache CXF. It is the most widely used Web Services Standard Now; Improvement over AXIS2, which is now gradually being replaced by Apache CXF
If you need help deciding between them, read this comparison (Apache CXF vs. Apache AXIS vs. Spring WS) for the pros and cons.
There's also this great answer about cxf and axis 2.

Resource for learning the details of Java Web Services?

I'd like to build a Java Web Service using JAX-WS and GlassFish 3. All of the guides showing the basics of Web Services in Java using tools like wsgen and wsimport to generate a lot of the boilerplate code to implement the Web Service. Is this just how it is done or does anyone know of some resources that go into more of the details?
IF you want to learn from the very beginning:
Heavyweight Web Services (SOAP/RPC) with JAX-WS
SOAP Contract (WSDL) and the Contract-first vs Code-First debate
Lightweight Web Services (RestFul) with JAX-RS
RESTFul Contract (WADL)
Web Service Deployment (Frameworks + JAX-* deployed in some App Servers)
Web Service Clients (i.e. usage of wsimport)
Introduction to Web Service Security, Addressing, etc
I recommend you Java Web Services. Up and Running by Martin Kalin. After that, if you need to go further with one of these subjects, I suggest you to get any of the 'cookbooks' published by O'Reilly.
Good starter point is Official Java EE Tutorial.

Why can't i create a RESTful web service in ejb module?

I am using Netbeans 6.8. I can see an option to create a web service in my independent ejb module but i can't seem to find an option to create a RESTful based web service in my ejb module. Is there any kind of restriction in ejb module that i can only create SOAP based web service and not RESTful? or is it the bug of Netbeans 6.8?
Chapter 2.6 of the EJB3 specs:
To support web service
interoperability, the EJB specification
requires compliant implementations to
support XML-based web service
invocations using WSDL and SOAP or
plain XML over HTTP incon- formance
with the requirements of the
JAX-WS[32], JAX-RPC[25], Web Services
for JavaEE[31], and Web Services
Metadata for the Java Platform [30]
specifications.
In other words: EJB3 can be exposed only as SOAP web service.
REST is just HTTP, usually implemented with servlets, so it would naturally be added to a WAR file that may or may not be packaged into an EAR with EJBs.
I don't believe that EJBs know or care about SOAP or REST. EJBs use RMI as their communication protocol of choice.
I found an article about EJB 3.1 and JSR-311 REST but I've to admit that I never tried it.
Write a wrapper class to the EJB which you are going to mark it as restful webservice with Jax-rs annotations with support of CXF rest api or Jersey api.

Categories

Resources