1. Integrar Tomcat en Eclipse
1.1 Pasos previos
Descargar eclipse de eclipse (vale cualquier versión de eclipse 3.4 ganymede o superior)
Descargar Tomcat 6.0.37 de tomcat
Descomprimir apache-tomcat-6.9.37.zip en un directorio [tomcat_home]
Descomprimir eclipse-jee-juno-SR2-win32.zip en un directorio [eclipse_home]
1.2 Crear un runtime de tomcat en Eclipse
Arrancar Eclipse
Window > Preferences > Server > Runtime Environments
Add...
Apache > Apache Tomcat v6.0
Next
Name: [tomcat_runtime]
Installation Directory: [tomcat_home]
JRE: el JRE que nos interese para ejecutar tomcat
Finish
2. Aplicación Web en Eclipse
2.1 Crear la aplicación
File > New > Other > Web > Dynamic Web Project
Name: [project_name]
Location: [project_location]
Target runtime: [tomcat_runtime]
Dynamic web module version: 2.5
Configuration: Default configuration for Apache Tomcat 6
Next
[app_name]
Next
Finish
Package Explorer > WebContent > New > JSP File
index.jsp
Introducir algún contenido a la página JSP, por ejemplo:
<%= new Date().toString() %>
2.2 Crear un servidor
Pestaña Servers
New server wizard
Apache > Tomcat v6.0 server
Host name: localhost
Server name: [server_name]
Server runtime: [tomcat_runtime]
Next
Añadir el proyecto
Finish
Botón derecho sobre el server > Start
URL: http://localhost:8080/[app_name]/index.jsp
2.3 Cambiar el puerto de tomcat
Doble click sobre el server en la pestaña Servers
Editar los puertos
Salvar
3. Web Service
3.1 Pasos previos
Descargar Apache Axis 2 de axis 2
Descomprimir axis2-1.6.2-bin.zip en [axis2_home]
3.2 Configurar Axis2 en Eclipse
Abrir eclipse.
Window > Preferences > Web Services > Axis2 Preferences
En la pestaña Axis2 Runtime, definir el directorio de Axis: [axis_home]
OK
3.3 Crear el proyecto del Web Service
Eclipse:
File > New > Other... > Web > Dynamic Web Project
Next
Project Name: [svc_name]
Location: [svc_dir]
Target runtime: [tomcat_runtime]
Dynamic Web Module Version: 2.5
Configuration:
Pulsar el botón Modify (junto a la configuración custom)
Marcar:
- Axis2 Web Services
- Dynamic Web Module
- Java
OK
Next
Next
En esta ventana podemos cambiar el [context_root] y el [content_dir]
Finish
3.4 Crear un servicio bottom-up
Un servicio bottom-up se crea definiendo la interfaz del servicio en Java y generando el WSDL a partir del interfaz Java. Por el contrario, un servicio top-down se crea definiendo el WSDL y generando las clases Java correspondientes.
Eclipse:
Package Explorer > [svc_name] > Java Resources > src > New > Package
[package_name]
Package Explorer > [svc_name] > Java Resources > src > [package_name] > New > Class
[class_name]
Definir operaciones dentro del servicio
Package Explorer > [svc_name] > Java Resources > src > [package_name] > [class_name].java
New > Other... > Web Services > Web Service
Next
Web Service type: Bottom up Java bean Web Service
Service implementation: [class_name]
En la escala del servidor poner: start service
En la escala del cliente poner: No client
Next
WSDL file: [wsdl_file]
Methods: Seleccionar los métodos que queremos que sean operaciones
Style and use: document/literal (wrapped)
Next
Pulsar el botón start server
Finish