XML-RPC server in EJB module - java

I'm wondering if it is possible to create XML-RPC server component within EJB module without servlets. I know EJB typically uses RMI as communication protocol but what if I want to omit RMI. What if i want to exchange data between EJB and web module (WAR) or other clients by different way like XML-RPC.
Can EJB-module work as stand-alone unit which will expose its state and services as XML-RPC server?
I still can do EJB module connected with WAR via RMI while this WAR will expose those services via servlet. Then other WARs or whatever-they-are clients can call this first WAR. Is this right or there is some other possibility?

What you probably want is to use Spring Remoting to expose your EJBs via for instance JAX-WS. Spring will create automatically servlets for handling the requests for you. The bad news is that you have to call your EJBs from the remoting services you build - meaning some boilerplate code. It should be quite straight forward though.
An other possibility you might take a look at is Restlet which can be used to build restful services.

In EJB3, your service beans are just annotated POJOs. You can simply annotate the same POJOs with #WebService (and the rest of this family of annotations) to expose the same services as web services.
I realize this isn't strictly what you asked for as the implementation for services exposed in this way is JAX-WS which uses SOAP messages. But I think it achieves your intent.

Related

Consumer Driven Contracts with SOAP web services

Does any of you know any approach or tools to implement Consumer Driven Contracts with SOAP web services? I have a legacy Java application that publishes SOAP web services, implemented with Apache CXF, which are consumed by a bunch of Spring Boot Java microservices. I’m already using Pact and Spring Cloud Contract to test my REST calls between the microservices, but could not find a way to use these same tools, or any other, for SOAP web services.
There is JavaSeifenBenutzer
a project to create Soap/Xml support for pact-jvm via a reverse proxy that converts XML to JSON and vice versa
You can use Spring Cloud Contract with MockMvc and RestDocs to build stubs of the XML service. Then you have to package the stubs in a jar for other people to reuse it and that's it.

Is there any rest testing tool which hosts the webservices and injects mocks in the facade layer?

I would like to know is there any api/tool which automatically deploys ear/war/war-inside-ear and then injects mocks in the facade layer to make it suitable for testing.
I heard that rest assured api is one such api. But I did not come across tutorials or example which explains how to write code to deploy the ear/war/war-inside-ear in a default web server(netty/jetty) and test the web services.
Till now we are deploying our ear in jboss(without any mock data) and testing the web services using aur own custom apis.
P.S.
I have an ear which contains a war module. All my web service classes are in it. To test the request and response of the web services, I am deploying the actual web services and other ejbs in a jboss instance which requires lot of effort and setup. And then I am testing the requests and responses of all web services.
I am looking for a tool which deploys the ear and inject mocks in the web service classes instead of initializing all the ejbs inside the ear. This will reduce my effort for the setup I have to do to get the ejbs run.

bridge framework between to different version of spring

We have have an application who have a service and dao layer. It use spring 3.2
We started to create a new web application who use spring 4 (client side and controller).
What could be the best technology to communicate both application? Both are not on the same server.
I know there is spring remoting, but I don't know if it's still a good solution.
I'd recommend exposing the service layer using contract first SOAP or REST web services. They'll be reusable by any client that can make an HTTP request, including your new app.
Spring remoting is a fine solution and only takes a few minutes get set up.

Spring beans (business layer) in separate module

I'm starting new application. I would like to have all business logic and domain classes separeted in standalone module (something like remote EJB). This is because of the app will have at least two (later more may be) clients - Desktop, Web (Spring MVC).
Is this possible with Spring? Or should I use EJB and Spring only for MVC in web app client?
Thank you for reply.
Yes, this can be done. You'll either put the resulting jar as a library in your full application, or host is separately and use some remoting system (hessian, soap, rmi, ...) to interface between them. Spring can help with that as well.

Apache CXF and Spring MVC

I have set up a CXF web service which works well. My service primarily loads data from an ftp to a db.
I would like to create a web interface through which the invoker can view the progress of their package. I thought it would be easy to integrate Spring MVC with CXF but there doesn't seem to be any good solution. I searched all over the net and could not find any thing simpler than this http://ayax79.wordpress.com/2009/02/19/making-spring-mvc-and-cxf-play-well-together/
The reason I would like to integrate Spring MVC with CXF and not create a stand alone web interface is because I have some custom Spring beans with in the CXF service which I can make use off to start and stop the process.
Is it that difficult to build an interface on CXF? Or am I just not thinking in the right direction?
The article you linked to has more to do with handling 1) web requests and 2) CXF requests within the same webapp, i.e. building a web application which can accept traditional http requests for MVC pages and also accept web service requests.
The author of that article seems to be pretty confused about Spring and how ApplicationContexts work, as the commenter Felix provides a good and simple solution for what the original author wants to accomplish (reuse the same bean definitions and instances within two contexts, having some URLs mapped to DispatcherServlet and other URLs mapped to a CXF dispatcher).
If you simply want your Spring MVC web application to be able to interact with and make requests to a CXF service, this is simple - you write code to consume the services as you would in any other type of application that interacted with a CXF/Soap/etc web service.
I'd recommend taking a look at the following sections in the Spring manual about access JAXRPC or JAXWS web services:
Accessing web services using JAX-RPC
Accessing web services using JAX-WS
Another option that you have is to simply generate client proxies for your CXF service using a tool like wsdl2java. Note that the next two options on this page I linked to, "JAX-WS Proxy" and "JAX-WS Dipatch APIs" do the same thing functionally as the Spring option above (creating a dynamic proxy at runtime).

Categories