Issue
- We have a WSDL (Web Services Description Language) descriptor and we need to build a client from it. Finally, we will make this service (client) available to any application installed on our Liferay instance.
Environment
- Liferay DXP 7.x
- wsimport tool from Oracle JDK 8.
Resolution
Implementation of the SOAP client
In order to call the SOAP service we need to create the stubs that will be our interface that will allow us to interact with the remote service through the SOAP protocol.
To create all the java code we need, starting from the WSDL document, we usually use the wsimport tool.
At this point all that remains is to run the wsimport command whose output will be the generation of the Java classes (stub). Now we have everything we need to be able to implement the SOAP client.
Configuration of the JAX-WS API and CXF EndPoints
Everything we have seen so far could not work until these two components are configured on the Liferay system:
- CXF EndPoints
- JAX-WS API
This configuration should only be necessary if we decide to develop and publish SOAP services on our Liferay instance.
Even if we act as a SOAP client we must configure these two components so that the JAX-WS provider is correctly configured and we can use the JAX-WS API without incurring any error.
The configurations for CXF and JAX-WS, and in particular the Context Path, can be consulted in following Liferay article: JAX-WS-and-JAX-RS
Additional Information
- This article is an abstract extracted from Antonio Musarra's one: https://www.dontesta.it/en/2019/09/05/how-to-implement-a-soap-client-using-jax-ws-liferay-infrastructure/