Consumer Driven Contracts with SOAP web services - java

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.

Related

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.

Java web service

I am new to web services and below I am sharing my understanding so far by reading on net:
Apache Axis and Apache CXF - are web services frameworks used to develop Java web services.
JAX-RS - Java API to develop Restful web services.
JAX-WS - Java API to develop SOAP web services.
Is the above correct? Or if you want to add something to it.
In my project, I am going to use web services with Spring framework.I am told that project will have both SOAP and RESTful web services.I am very much new to this.
Can somebody please guide me in this regard by sharing some valuable information or any good link which will make me understand better?
Your statements are correct, but it's not clear whether you've understood one crucial fact: CXF and Axis are both implementations of the JAX-WS standard. CXF additionally implements JAX-RS, and there are some libraries that only implement JAX-RS, such as Jersey (Oracle's reference implementation) and RESTEasy from JBoss.
For your project, the big question is whether you will only consume those webservices, or also publish them. If you need to publish a webservice, you'll have to include the entire implementation library and learn to use it. If you only consume the services, you'll just need some generated client and data binding classes.
Another question is whether your RESTful services will talk XML or JSON (SOAP always uses XML), as you'll need a parser or binding framework for JSON (JAX-B for XML is included in recent JDKs).

Java framework to use for JSON based web service

I am in the process of writing a JSON based web service. The service will accept two types of requests: commands (e.g. createOrder) and queries (e.g. getOrders). Each request needs to send user credentials (username/password) for authentication (perhaps in HTTP headers). The service needs to be implemented in Java.
Which frameworks would you recommend for this use case? The very basic stack that I am thinking of is servlets backed by a JSON framework like Jackson. Are they any other frameworks that you would recommend and why? There is no need or desire to make the service RESTful, however smooth integration with Java EE 6 or Spring would be a plus.
Thanks in advance for your time.
Can I then interest you in RESTful Web Services (which is a JAX-RS API)? A library that implements JAX-RS is Jersey, Apache CXF, which is suited to allow JSON Web Service.
A related StackOverflow Post which shows REST clients that conforms to JAX-RS.
You should take a look at spring mvc and read this blog post which cover using spring mvc for restful WS.
Play! Framework would definitely fit your bill. It is not servlet-based but fulfills all of your requirements. Plus development with Play is very fast, you can get a prototype up and running in no time.
I personally use Apache CXF, with JAX-RS and jackson libraries. They are easy to implement and integration is dead easy. JAX-RS is a java standard, Jackson library is fast and handles circular references and Apache CXF needs only a couple of lines of configuration to setup and start running. Go for it!
An Open-Source Services Framework From Apache
-CXF has been designed to provide a pluggable architecture that supports not only XML but also non-XML type bindings, such as JSON and CORBA, in combination with any type of transport.
-Java EE integration: deploy services in Java EE application servers such as Apache Geronimo, JOnAS, Redhat JBoss, OC4J, Oracle WebLogic, and IBM WebSphere
-Standalone Java client/server

XML-RPC server in EJB module

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.

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