Today we will create a SOAP Web Service, based on LebrijoSchool project which we were making in early weeks over Oracle-Weblogic Architechture.

First of all is to add the Web Services facet. Right button > Properties … :

Add WS facet

After, we will create the class from a Spring Service class. Right button > New > WebLogic Web Service for Spring Beans:

Expose Spring as a WS

Choose the Service, and the methods that we want to publish as Web Service.

Finally put it in the logical package: lebrijo.school.webservices. And name it as “SchoolCertificatesWS”.

This is the code:

	@Autowired
	@Qualifier("RegistryService")
	private IRegistryService springServ;
 
	@WebMethod
	public Registry findRegistryById(java.lang.String id) throws Exception {
		return springServ.findRegistryById( id );
	}

We have a Weblogic client to test the WS, we can acces thru the URL http://localhost:7001/wls_utc/.

Hoy crearemos un servicio web SOAP, basándonos en el proyecto LebrijoSchool que hemos venido haciendo sobre la arquitectura Oracle-Weblogic en artículos anteriores.

Lo primero es añadir el facet de Web Services. Botón derecho > Properties … :

Add WS facet

Después, creamos el WS a partir de una clase de servicio de Spring. Botón derecho > New > WebLogic Web Service for Spring Beans:

Expose Spring as a WS

Elegimos el servicio, y los métodos que queremos publicar publicar como WS.

Finalmente lo ponemos en el paquete adecuado: lebrijo.school.webservices. Y le damos un nombre “SchoolCertificatesWS”.

Nos queda un WS con este código:

	@Autowired
	@Qualifier("RegistryService")
	private IRegistryService springServ;
 
	@WebMethod
	public Registry findRegistryById(java.lang.String id) throws Exception {
		return springServ.findRegistryById( id );
	}

Para ver como funciona en WS tenemos un cliente en Weblogic, al que podemos acceder a través de la URL http://localhost:7001/wls_utc/.

Para implementar la capa de servicios y aprovechar su inyección de dependencias vamos a utilizar Spring.

Con Spring 2.5.6, que es la versión soportada por OEPE, para acomodar nuestro desarrollo.

Primero añadimos la Facet de Spring a nuestro proyecto. En el menu contextual del proyecto > Properties… :

Add Spring Facet

Luego generamos las clases ORM. Se generan con el menú contextual del proyecto > Spring > Generate Spring ORM Classes …

Creating new ORM Services

Como se observa, sobre las entidades JPA definidas en nuestro paquete de persistencia, se definen las clases de acceso y las de servicio. Os recomiendo echarle un buen vistazo a los paquetes lebrijo.school.services y lebrijo.school.dao.

Lo normal es que debamos limpiar estas clases de métodos, ya que genera todas las posibilidades (remove, persist, findById,…). Por ejemplo, si una entidad de nuestro modelo es una vista, no tendrá sentido mantener un DAO con los métodos persist y remove.

Aquí os dejo el zip del proyecto eclipse tras estas modificaciones.

In order to make the service layer and use the dependency injection we will take Spring.

Spring 2.5.6 is the OEPE default version supported.

First we will add the Spring Facet to our project. Right mouse button over the project > Properties… :

Add Spring Facet

After genertate the ORM classes. They will generate with contextual menu > Spring > Generate Spring ORM Classes …

Creating new ORM Services

You can see, about the JPA defined in our persistence package, it will create th access classes and services ones. I recommend you see the lebrijo.school.services and lebrijo.school.dao packages.

After we must clean this class of methods, the generator generates all possibilities (remove, persist, findById,…). For example, if one entity of our model is a view, we can destroy persist or remove methods.

Here I keep the zip eclipse project after these steps.