Does Dropwizard support Server Sent Event? [duplicate] - rest

Does Dropwizard support Servlet 3 asynchronous servlets? If not, is it on the roadmap at any time in the near future?

It uses Jetty 8, which supports Servlet 3.0. Jersey (and JAX-RS) doesn't have any support for this, but it's forthcoming in JAX-RS 2.0 (and Jersey 2.0). Dropwizard doesn't add anything special, but when Jersey 2.0 ships, the next major Dropwizard release will very likely include it.

You can use https://github.com/jetty-project/jetty-eventsource-servlet. Read wiki for how to impl Servlet and EventSource
In your DW Service implementation you add your SSE servlet
environment.addServlet(new MySseEventSourceServlet(), "/sse");
Then add this to your DW config
http:
connectorType: NONBLOCKING
now you can start listening for Server-sent Event's on
<host>:<port>/sse
ex.
curl localhost:8080/sse -H"Accept: text/event-stream"
See working example # GitHub, https://github.com/andershedstrom/dropwizard-with-sse

Related

REST Api documentation for Apache CXF application

We use Apache CXF in our application with jax-rs to build REST Api. As of now, there is no documentation about the various endpoints available and is deployed on Tomcat 8.5 server.
I have done some R&D on how to find a solution. I understand that Swagger can be used.
But, I did not find enough documentation to user swagger with Apache CXF.
I understand that these type of questions are prohibited in the site. At the same time, I am not sure which chat room to use for this purpose.
Any information on this would help me a lot.
Depending on the CXF version that you are using, I would suggest to use OpenApiFeature (OpenAPI is newer than Swagger) as described here: http://cxf.apache.org/docs/openapifeature.html
You can also find multiple sample projects with Swagger or OpenAPI here: https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs

How to send HTTP 2.0 request in play framework(scala)

Backend running under play framework(v. 2.6.5 scala) must communicate with Apple Push Notificaton Service (APNs) . APNs requires using HTTP/2, and so i tried to find any way to implement such communication, but to my surprise i didn`t find any http scala clients, supporting http v 2.0.
Is there any way to realize such communication without going out of the framework?
Thanks!
Play Framework with a version prior to 2.6 does not support HTTP 2.0, but, Play Framework 2.6 is based on Akka-Http and has experimental support for HTTP 2.0. This feature is labeled "experimental" because the API may change in the future, and it has not been thoroughly tested in the wild.
To add support for HTTP/2, add the PlayAkkaHttp2Support plugin. You can do this in an enablePlugins:
lazy val root = (project in file("."))
.enablePlugins(PlayScala, PlayAkkaHttp2Support)
If you consider alternatives take a look at:
Jetty has a capability to use HTTP 2.0
Netty also supports HTTP 2.0
Check this list of known implementations of HTTP 2.0.
In Akka HTTP, which underlies Play! Framework, HTTP/2 support is experimental on the server side and not yet available on the client side, as far as I can tell. Work is in progress and is tracked on Github. Unless you're inclined to write HTTP/2 client support yourself and optionally donate it to the project (which would probably be a very satisfying experience), going outside of the framework is probably going to be a necessity for now, I'm afraid.
If you're in a position to use Java 9 (hey, it's been gold for two days!), you might consider its HTTP/2 client.
Vert.x is originally a Java framework inspired by NodeJS, but in its current incarnation it includes an HTTP/2 client with a Scala API: http://vertx.io/docs/vertx-web-client/scala/ - I've never used it in production so YMMV...
Edit: you might also consider sttp with the OkHttp backend, which supports HTTP/2.

Domino client web services and SOAP 1.2

I create a client in Domino to consume a web service that works with SOAP 1.2 and has HTTPBinding.
The client generation tool for Domino Designer Web services an error is displayed when trying to generate reporting that the SOAP accepted version is 1.1.
I decided to create the client with CXF framework through tool wsdl2java. In an agent I used these classes to consume the web service, however the below error was displayed. I think it's because of the SOAP version, but I'm not sure.
com.sun.xml.internal.ws.protocol.soap.MUTube getMisUnderstoodHeaders
INFO: Element not understood={http://www.w3.org/2005/08/addressing}Action
Also generated a jar of classes generated by wsdltojava and imported to another agent, but the error below is displayed.
java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=, offset=6
The question is, no way consume a web service with SOAP 1.2 in Domino only supports up to version 1.1?
Thanks a lot!
I don't believe that Domino's web service consumer supports SOAP 1.2 at this time. You might be able to do what you need with an agent though - here's one way: How can I call a SOAP 1.2 Web service from a LotusScript agent?
In fact there is no way to natively consume a web service with soap version 1.2. There are already several requests from IBM to upgrade the SOAP version. What I did, was to develop a new layer through a new web service with the version SOAP 1.1, which internally calls the web service with the SOAP version 1.2;

JAX-RS Frameworks with Client Caching

Do RESTEasy, Jersey or Restlet integrate client sided caching?
I read something about a CacheClient for Jersey
Is that an official implementation? If not, are they working on Client Caching for Jersey 2.0? Can someone confirm this?
For Resteasy I read here something about official client sided cache control.
Im not sure about Restlet. Are there some official good solutions?
Regarding Restlet, we are planning to add a caching service in version 2.2. That will benefit the JAX-RS extension as well.
See our detailled roadmap here.

Define WADL resources base in Jersey

I am using Jersey 1.9 and it is generating my WADL perfectly except I need to redefine the resources base URI.
I'm running Jetty 7 sitting behind Apache using mod_proxy as a reverse proxy to route REST requests back to Jetty / Jersey. So Jersey generates the resources base URI as
http://localhost:8080/testRestAPI/rest/
when I need something like
http://mydomain.com/rest/
I found this from Google but it is not working: http://jersey.576304.n2.nabble.com/Changing-baseURI-when-generating-WADL-td6169703.html
unfortunately, you've found a bug in Jersey implementation. Please file a new issue as stated on mailing list - jira link: http://java.net/jira/browse/JERSEY
What you can do for now is downgrade to Jersey 1.8, which should not be affected by latest changes in this area. Thanks and sorry for inconvenience!
EDIT: issue link: http://java.net/jira/browse/JERSEY-773
it is already fixed, so you should be able to use this feature in Jersey 1.10-b02 and newer.