2 Parte – Hessian: Integración de Hessian con Spring Framework…
Java, Programación, Spring, Web Services 26 de January del 2010
Bueno, como he dicho antes con un poco de práctica y sobre todo, con mucho interés se pueden saber las cosas que uno quiere… después de mucha lectura sobre como crear un Web Services con Hessian integrándolo con Spring púes he conseguido levantar el cliente y el servidor, pero me encontré con muchos problemas que principalmente fueron de versiones, y como he leído en muchos foros, no se puede obtener una respuesta correcta por parte del servidor en spring 2.5.xx así que tuve que download la versión 3.0.0 release:
Tomamos como ejemplo el proyecto que creamos en el post “1 Parte – Hessian… ” y sólo hay que crear:
1.- remoting-servlet.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="userServices" class="com.serunix.services.impl.UserServicesImpl" /> <bean name="/userService" class="org.springframework.remoting.caucho.HessianServiceExporter"> <property name="service" ref="userServices"/> <property name="serviceInterface" value="com.serunix.services.UserServices"/> </bean> </beans> |
2.- Modificamos nuestro web.xml y agregamos esto.
1 2 3 4 5 6 7 8 9 10 11 12 | ...
<servlet>
<servlet-name>remoting</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>remoting</servlet-name>
<url-pattern>/remoting/*</url-pattern>
</servlet-mapping>
... |
3.- Y quitar que la clase UserServicesImp ya no extienda de HessianServlet
1 | ... extends HessianServlet ... |
4.- Esto tendría que ser suficiente para el servidor y por parte del cliente, sólo hay que agregar:
5.- remoting-servlet-client.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <bean id="userService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"> <property name="serviceUrl" value="http://localhost:8080/EJEMPLOHESSIAN/remoting/userService"/> <property name="serviceInterface" value="com.serunix.services.UserServices"/> </bean> </beans> |
6.- Y para obtener la llamada sólo hay que hacer la petición a la Url que configuramos en el servidor /userService
1 2 3 | ApplicationContext context = new ClassPathXmlApplicationContext("classpath:test/serunix/remoting-servlet-client.xml");
UserServices userservices = (UserServices) context.getBean("userService");
List users = userservices.ObtainListUsers(); |
7.- Así que esto sería todo, aquí les dejo un screenshot de como quedo mi proyecto incluyendo los jars…
Sobre mí







Información Bitacoras.com…
Valora en Bitacoras.com: Bueno, como he dicho antes con un poco de práctica y sobre todo, con mucho interés se pueden saber las cosas que uno quiere… después de mucha lectura sobre como crear un Web Services con Hessian integrándolo con Spring púes h…..