Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to remotely expose a bean in spring boot using REST and httpInvoker

I need to expose some service for remote use by Java clients (they shall use httpinvoker) and other languages (they shall use REST).

Can I configure spring boot to expose both ? (I would not mind if two separate instances with different ports would be used, like in this post).

I dumped the idea of providing an API for the Java clients that internally uses REST because it is rather tedious to wire all REST endpoints into the code manually using RestTemplate. I like the concept of HttpInvoker because a ProxyFactoryBean gets used automagically. If Spring Remoting would be able to do this in a way it can be done for JMS, AMQP and the others I would head this way.

like image 419
Marged Avatar asked Apr 21 '15 20:04

Marged


People also ask

Which of the following remoting technologies are supported by Spring?

Spring framework supports following remoting technologies: Remote Method Invocation (RMI) Spring's HTTP invoker. Hessian.

How does Spring remoting work?

The Spring approach to HTTP Remoting allows clients to communicate with the Spring-hosted server code via HTTP without the client code requiring any knowledge of HTTP being used. Instead, the client Java code only "sees" normal business-related Java objects (usually interfaces) rather than HTTP-specific objects.

How can we achieve serialization in Java through HTTP using Spring?

Spring provides a special remoting strategy which allows for Java serialization via HTTP, supporting any Java interface (just like the RMI invoker). The corresponding support classes are HttpInvokerProxyFactoryBean and HttpInvokerServiceExporter. Hessian.

What do you have to do when you are using the RMI Spring remoting support?

Spring rmi remoting example. Now we need to create one main method where we will look up the implementation interface bean from the spring context. Once we have the instance, we can now call the server-side method just like any other local java method invocation.


1 Answers

You can use something like this. Expose your services as a rest service. Then make your java clients to consume those services using http or some other library. If any other party is interested also, they can consume it in their own way too.

Else you can create your own jar consuming your rest services and let your java clients use that, without the knowledge about the rest service.

like image 68
Maleen Abewardana Avatar answered Sep 23 '22 20:09

Maleen Abewardana