國立台灣科技大學 – 資訊管理 – IDSL 
2014 
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
2 
1. Table of Contents 
1. TABLE OF CONTENTS ................................................................................ 2 
2. DEVELOPMENT TOOLS ................................................................................ 3 
2.1 DEVELOPMENT ENVIRONMENT .......................................................................... 3 
2.2 TOMCAT INSTALLATION .................................................................................... 3 
2.3 CONFIGURING FIREWALL ................................................................................... 9 
2.4 AXIS2 INSTALLATION ...................................................................................... 14 
2.5 INSTALL THE NECESSARY JAR FILES ............................................................... 19 
2.6 SETTING UP ECLIPSE ....................................................................................... 20 
3. BUILD A WEB SERVICE PROGRAM ........................................................ 23 
3.1 CREATE A NEW PROJECT .................................................................................. 23 
3.2 CREATE JAVA CLASS ....................................................................................... 26 
3.3 CREATE A SERVER ........................................................................................... 28 
3.4 STARTING WEB SERVICES ............................................................................... 31
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
3 
2. Development Tools 
Service: 
 Tomcat (http://tomcat.apache.org/) 
Web service deployment and development engine: 
 Apache Axis2 (http://axis.apache.org/axis2/java/core/) 
 Codehaus XFire (http://xfire.codehaus.org/) 
 Apache CXF (http://cxf.apache.org/) 
 JWSDP (Java Web Services Developer Pack) 
IDE: 
 Eclipse (http://www.eclipse.org/) 
2.1 Development environment 
Software version: 
 Tomcat v7.0.42 
 Apache Axis2 v1.6.2 
 Eclipse Java EE IDE for Web Developers 
2.2 Tomcat installation 
Download stable version of tomcat from http://tomcat.apache.org. In this document we will use Apache Tomcat v7.0.42 and it can be downloaded from http://tomcat.apache.org/download-70.cgi, it can be seen on Figure 1. Choose 32- bit/64-bit Windows Service installer to download apache-tomcat-7.0.42.exe. 
Figure 1. Apache Tomcat download page
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
4 
Follow these steps below to install and configure Apache Tomcat: 
1. Run the Apache Tomcat’s installer and accept the installation agreement as seen in Figure 2 and Figure 3. 
Figure 2. Apache Tomcat’s installation setup wizard 
Figure 3. Apache Tomcat’s license agreement
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
5 
2. When asked about installation type, choose Normal. (see Figure 4. for the detailed information) 
Figure 4. Apache Tomcat’s installation type 
3. Configure your Apache Tomcat’s installation. Set up your account’s User Name and Password in the corresponding field. (see Figure 5. for the detailed information) 
Figure 5. Apache Tomcat Setup: Configuration Options
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
6 
4. Select the path of Java SE or JRE installed on your computer. (see Figure 6. for the detailed information) 
Figure 6. Apache Tomcat Setup: Java Virtual Machine path selection 
5. Choose the destination folder to install the Apache Tomcat. (see Figure 7. for the detailed information) 
Figure 7. Apache Tomcat’s destination folder
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
7 
6. After choosing the Apache Tomcat’s installation folder, wait for the installation setup to finish its process. After the installation has finished, the setup wizard will looks like Figure 8. 
Figure 8. Finished installation Apache Tomcat 
7. To start Apache Tomcat, open up its configuration by: (WinKey)Start > All Programs > Apache Tomcat 7.0 Tomcat7 > Configure Tomcat ↵. Then, when it displays window such as in Figure 9, press the Start button. 
Figure 9. Apache Tomcat 7.0 configuration window
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
8 
8. When Apache Tomcat first running on your system, usually it will display a pop- up confirmation window asking permission for a program (Apache Tomcat) to communicate through your computer’s firewall. Allow this program to communicate through your firewall. 
9. Open up your browser and go to http://localhost:8080. It will display a webpage which is located in the install location that have been selected before. In our case, the directory of the webpage would be in “C:Program FilesApache Software FoundationTomcat 7.0webappsROOT” (see Figure 10.) 
Figure 10. Default Webpage display of Apache Tomcat
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
9 
2.3 Configuring firewall 
After Apache Tomcat’s installation, make sure that port 8080 (default port used by Apache Tomcat) has been enabled on your computer. To activate port 8080 through your computer’s firewall, follow these steps: 
1. Open up Windows Control Panel through Start Menu (see Figure 11.). 
Figure 11. Open Start menu and select Control Panel 
2. On control panel window under the category of System and Security, choose Windows Firewall (see Figure 12). 
Figure 12. Select Windows Firewall on Windows’ System and Security window
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
10 
3. On windows firewall’s window, choose “Advanced settings” from the sidebar (see Figure 13). 
Figure 13. Choose “Advanced settings” on Windows firewall sidebar 
4. On windows firewall advance settings’ window, click on “Inbound Rules” and then click on “New rule…” to add new rule that will allow Apache Tomcat to use port 8080 through Windows Firewall (see Figure 14). 
Figure 14. Add new inbound rule into windows firewall 
5. In the New Inbound Rule Wizard, choose Port as the rule type and then press button “Next” (see Figure 15).
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
11 
Figure 15. Select “Port” as the rule type in New Inbound Rule Wizard 
6. Select “TCP” as the protocol and input “8080” as the port number (see Figure 16). 
Figure 16. Select “TCP” as the protocol type and “8080” as the port number
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
12 
7. Select “Allow the connection” as the action to be taken (see Figure 17). 
Figure 17. Choose “Allow the connection” on the action selection 
8. Check on all options in the profile section (see Figure 18). 
Figure 18. Check all options in the profile section
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
13 
9. Give a name on the newly created inbound rule in the corresponding field, in this example: tomcat (see Figure 19). After giving a name to the new inbound rule, press button “Finish” to complete the process. 
Figure 19. Give a name to the newly created inbound rule
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
14 
2.4 Axis2 installation 
Download stable version of Apache Axis2 from http://axis.apache.org/axis2/java/core/download.cgi. In this document we will use Apache Axis2 v1.6.2. Download binary distribution of the Apache Axis2 v1.6.2 (http://apache.cdpa.nsysu.edu.tw//axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip). Follow these steps below to configure Apache Axis2: 
10. After downloading axis2-1.6.2-bin.zip, extract the file to C:axis2-1.6.2. 
11. Open up your computer properties and then select “Advanced system settings” from the sidebar menu (see Figure 20). 
Figure 20. Open computer’s properties and select “Advanced system settings” 
12. On the advanced system settings window, click on the button “Environment Variables…” as seen on Figure 21. 
Figure 21. Click button “Environment Variables…” on the advanced system properties window
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
15 
13. On the environment variable window, add a new system variables by clicking button “New…” (see Figure 22). 
Figure 22. Add new system variables 
14. On the new system variable window, set the variable name as “AXIS2_HOME” and variable value as the directory of the extracted Apache Axis2 file (C:axis2- 1.6.2). After finish setting up the new system variable, click button “OK” (see Figure 23). 
Figure 23. New Apache Axis2 system variable
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
16 
15. Download axis2-1.6.2-war.zip from http://ftp.mirror.tw/pub/apache//axis/axis2/java/core/1.6.2/axis2-1.6.2-war.zip and extract the downloaded file to any directory. 
16. Open your browser and go to http://localhost:8080/ and then click on “Manager App” button (see Figure 24). 
Figure 24. Click on “Manager App” button on the Apache Tomcat page 
17. On Tomcat Web Application Manager’s page, upload the extracted file axis2.war by clicking on button “Choose File” under the “Deploy” group. After selecting the file to be uploaded, click on the “Deploy” button (see Figure 25). 
Figure 25. Deploy the Web application ARchive (WAR) file
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
17 
18. If the Web application ARchive (WAR) file has been successfully deployed, it will be displayed under the list of Applications (see Figure 26). 
Figure 26. Successfully uploaded and deployed WAR file 
19. After axis2 has been deployed, go to http://localhost:8080/axis2/ on the new tab of your browser, and it will display a page such as in Figure 27. 
Figure 27. Successfully deployed axis2 web application
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
18 
On the axis2 homepage, there are three (3) available links: 
Link 
Function 
Services 
View the list of all the available services deployed in this server. 
Validate 
Check the system to see whether all the required libraries are in place and view the system information. 
Administration 
Console for administering Axis2 installation. Axis2 provide one user account by default. 
User Name : 
admin 
Password : 
axis2 
20. To change the default User Name and Password, go to Apache Tomcat installation directory (C:Program FilesApache Software FoundationTomcat 7.0webappsaxis2WEB-INFconf). Open axis2.xml file and look for the following line: 
<parameter name="userName">admin</parameter> <parameter name="password">axis2</parameter> 
Edit the parameter value and do not forget to save the file after you finished editing.
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
19 
2.5 Install the necessary JAR files 
Open up your browser and go to http://www.java2s.com/Code/Jar/CatalogJar.htm. Download activation.jar, mail.jar, tools.jar, xmlsec.jar and put it insides lib folder in your Apache Tomcat installation folder (see Figure 28). For example: C:Program FilesApache Software FoundationTomcat 7.0lib. 
Figure 28. Store activation.jar, mail.jar, tools.jar, and xmlsec.jar inside lib folder Copy all files inside C:axis2-1.6.2lib to C:Program FilesApache Software FoundationTomcat 7.0lib.
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
20 
2.6 Setting up Eclipse 
Follow these steps below to configure eclipse: 
1. Open Eclipse. 
2. On the menu bar, select Window  Preferences. 
3. Select Server  Runtime Environments  Add. 
4. On the New Server Runtime Environment, choose Apache Tomcat v7.0 and then press button “Next” (see Figure 29). 
Figure 29. Choose Apache Tomcat v7.0 as the new server runtime environment 
5. Assign the Tomcat installation directory and then press button “Finish” (see Figure 30).
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
21 
Figure 30. Assign Apache Tomcat installation directory into eclipse 
6. Back to eclipse’s preferences window, now select Web Services  Axis2 Preferences. Set Axis2 runtime location with the directory of extracted axis2- 1.6.2 in your computer, e.g. C:axis2-1.6.2 (see Figure 31). 
Figure 31. Assign Axis2 runtime location
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
22 
7. Back on the Web Services, now select Server and Runtime. Change the value of Web service runtime from Apache Axis to Apache Axis2 (see Figure 32). 
Figure 32. Change the value of Web service runtime to Apache Axis2
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
23 
3. Build a Web Service Program 
This part will describe the process to create a web service program. 3.1 Create a new project 
Follow these steps below to create a new project for the web service program: 
1. Create a new project for the web service program by selecting “File  New  Other  Web  Dynamic Web Project” on the Eclipse menu bar (see Figure 33). After selecting to create a dynamic web project, click on the “Next” button. 
Figure 33. Create new dynamic web project in Eclipse 
2. Fill in the project name (e.g. idsl-web-service) and set the dynamic web module version to version 2.5 (see Figure 34).
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
24 
Figure 34. Configure the new web service project 
3. Click on “Modify” button to set project configuration (see Figure 34). On the project configuration window, check “Axis2 Web Services” option and then press button “OK” (see Figure 35). 
4. After finish adding “Axis2 Web Services” on the project configuration, click button “Finish” to create the project.
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
25 
Figure 35. Check “Axis2 Web Services” on the project configuration window
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
26 
3.2 Create Java class 
Follow these steps below to create Java class for your web service project: 
1. Right click on the web service project and then on the pop-up menu select “New  Class” (see Figure 36). 
Figure 36. Create new Java class inside the web service project 
2. Assign a name (e.g. HelloWorld) for the new Java class to be created then click on button “Finish” to create the class (see Figure 37). 
3. Try to put some code into the created class (see Figure 38).
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
27 
Figure 37. Create HelloWorld class 
Figure 38. Try put on some code into HelloWorld class
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
28 
3.3 Create a server 
To create a server, follow these steps below: 
1. There are two ways to create a server, via Eclipse’s menu bar or Eclipse’s Servers page. 
The first way to create server is by selecting “File  New  Other…” on Eclipse’s menu bar. Then choose “Server” from the list as shown in Figure 39. 
Figure 39. Create new server from Eclipse menu bar Another way to do this is via Eclipse’s Servers window. Right click on Eclipse Servers’ page and then choose “New  Server” from pop-up menu as shown in Figure 40. In case Eclipse’s Servers page is not displayed, select “Window  Show View  Servers” from the menu bar. 
Figure 40. Create new server from Eclipse Server window
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
29 
2. Choose “Tomcat v7.0 Server” from the list of server type and then click button “Finish” (see Figure 41). 
Figure 41. Create new Tomcat v7.0 server 
3. In the Servers page, double click on the server that you have just created to open up the general information about the server. Then change the server locations to “Use Tomcat Installation (takes control of Tomcat installation)” (see Figure 42).
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
30 
Figure 42. Change the server location to “use tomcat installation”
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
31 
3.4 Starting Web Services 
To start the web service, expand the Eclipse project explorer and look for class java file that has been created (e.g. HelloWorld.java). Right click on that file and from the pop-up menu choose “Web Services  Create Web Service” as shown in Figure 43. 
Figure 43. Create web service for HelloWorld.java Check the created web service’s configuration and make sure that the “Web service runtime” is set to “Apache Axis2” as shown in Figure 44, then click on button “Next”. If the “Web service runtime” is not set to “Apache Axis2”, then change its value by clicking on the web service runtime’s link and change its value to Apache Axis2 as shown in Figure 45.
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
32 
Figure 44. Make sure that web service runtime is set to Apache Axis2 
Figure 45. Choose Apache Axis2 as the web service runtime
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
33 
After clicking button “Next”, do not forget to choose “Generate a default services.xml file” as shown in Figure 46. 
Figure 46. Generate a default services.xml file After clicking on “Finish” button, do not forget to start the Tomcat server by clicking “Start server” button (see Figure 47). 
Figure 47. Click on button “Start server” to start the Tomcat server
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
34 
After starting the Tomcat server, open up your browser and go to http://localhost:8080/<your-web-service-project-name>. In this tutorial the address would be http://localhost:8080/idsl-web-service/ (see Figure 48). Click on the “Services” link to see all available services run on the server. In this tutorial you will see the HelloWorld Web service as shown in Figure 49. 
Figure 48. The display of idsl-web-service 
Figure 49. The display of all available services on idsl-web-service
Web Services Using Java 
Tomcat + Axis2 + Eclipse 
羅乃維, Alexander Yohan 
國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 
35 
Try clicking on the HelloWorld web service to make it shows the WSDL as shown in Figure 50. 
Figure 50. HelloWorld web service’s WSDL Use RESTful to test the return value from the code in file HelloWorld.java. In your browser go to http://localhost:8080/<your-web-service-project- name>/services/<service-name>/<function-name>?<parameter- name>=<parameter-value>. In this tutorial, the address would be: 
http://localhost:8080/idsl-web- service/services/HelloWorld/printName?name=Alexander. (see Figure 51) 
Figure 51. Use RESTful to test the return value

More Related Content

PDF
Fcm rapid-install-11122-1634210
PDF
Installing java, eclipse and maven
DOCX
Installation of oracle 12c RAC on linux vm
PDF
Obiee installation guide v2
PDF
Install oracle database 12c software on windows
PDF
TWaver Flex Performance Report
DOC
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
PDF
Install sccm 2007 on windows server 2008 r2 – step by step
Fcm rapid-install-11122-1634210
Installing java, eclipse and maven
Installation of oracle 12c RAC on linux vm
Obiee installation guide v2
Install oracle database 12c software on windows
TWaver Flex Performance Report
( 16 ) Office 2007 Create An Extranet Site With Forms Authentication
Install sccm 2007 on windows server 2008 r2 – step by step

What's hot (18)

PDF
Oracle vm-installation
PDF
Software industrialization
PDF
2v0 620 Exam-vSphere 6 Foundations
DOCX
How to install oracle ops center 12c
PPTX
How to install Java and how to set the path
PDF
Mc sl54 051_ (1)
PDF
2010 frc-control system
PPT
Servlet 3.0
PDF
WebLogic, 12C SOA Standalone installation
DOCX
Oracle Web logic 12c on docker
PDF
Obiee 11g installation
PPTX
March 2018 Patch Tuesday Ivanti
PDF
JEE Programming - 01 Introduction
PPTX
Oracle SOA 12.2.1 Installation
PPT
Apache Tomcat 7 by Filip Hanik
PDF
Dinesh Gupta Discoverer
PDF
Installing Oracle Endeca Information Discovery 3.0
PDF
Oracle RAC 11g Rel2 11201 installations
Oracle vm-installation
Software industrialization
2v0 620 Exam-vSphere 6 Foundations
How to install oracle ops center 12c
How to install Java and how to set the path
Mc sl54 051_ (1)
2010 frc-control system
Servlet 3.0
WebLogic, 12C SOA Standalone installation
Oracle Web logic 12c on docker
Obiee 11g installation
March 2018 Patch Tuesday Ivanti
JEE Programming - 01 Introduction
Oracle SOA 12.2.1 Installation
Apache Tomcat 7 by Filip Hanik
Dinesh Gupta Discoverer
Installing Oracle Endeca Information Discovery 3.0
Oracle RAC 11g Rel2 11201 installations
Ad

Viewers also liked (13)

PDF
lesson3 JSP
PDF
6 - functions
PDF
PDF
lesson3 JSP
PDF
lesson2 JSP
PDF
1. ความรู้เกี่ยวกับการ web programming
PDF
lesson1 JSP
PDF
Java Web Services and SOA Exercises [in Thai]
PDF
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
PDF
lesson4 JSP
PDF
01 ความรู้เกี่ยวกับการ web programming
PDF
Java Web Programming (JSP/Servlet) Using Eclipse and Tomcat
PDF
Software Park Thailand Newsletter (Thai) Vol2/2556
lesson3 JSP
6 - functions
lesson3 JSP
lesson2 JSP
1. ความรู้เกี่ยวกับการ web programming
lesson1 JSP
Java Web Services and SOA Exercises [in Thai]
็Hand-on Exercise: Java Web Services using Eclipse + Tomcat & NetBeans + Glas...
lesson4 JSP
01 ความรู้เกี่ยวกับการ web programming
Java Web Programming (JSP/Servlet) Using Eclipse and Tomcat
Software Park Thailand Newsletter (Thai) Vol2/2556
Ad

Similar to web services using java (20)

PDF
Rt2870 Software Release Note For Windows Ce
PDF
Laporan Praktikum Keamanan Siber - Tugas 1 - Kelas C - Kelompok 3.pdf
PDF
TAFJ-AS WebLogicInstall.pdfDDDDDDDDDDDDDDDDDDDDDDDDDDD
PDF
Oracle_Retail_Xstore_Suite_Install.pdf
DOCX
Integrate UFT with Jenkins Guide
PDF
Spring Live Sample Chapter
DOCX
obiee 12c installation guidelines
DOCX
05 160723204945
PDF
Obiee 11.1.1.5 installation and configuration guide
PDF
Building A Simple Web Service With CXF
PDF
Solution Manager Technical Monitoring - BOBJ (Part 2 of 3 - Auto-Configure)
PDF
Microsoft Lync Server 2010 Installation
PDF
Oracle bi 10g_install_migration
PDF
PDF
Steps how to create active x using visual studio 2008
PDF
Forti gate troubleshooting_guide_v0.10
ODP
Power ai image-pipeline
PDF
Integrating Tomcat And Apache On Windows
PDF
Tomcat tutorail
PDF
Keycloak Single Sign-On
Rt2870 Software Release Note For Windows Ce
Laporan Praktikum Keamanan Siber - Tugas 1 - Kelas C - Kelompok 3.pdf
TAFJ-AS WebLogicInstall.pdfDDDDDDDDDDDDDDDDDDDDDDDDDDD
Oracle_Retail_Xstore_Suite_Install.pdf
Integrate UFT with Jenkins Guide
Spring Live Sample Chapter
obiee 12c installation guidelines
05 160723204945
Obiee 11.1.1.5 installation and configuration guide
Building A Simple Web Service With CXF
Solution Manager Technical Monitoring - BOBJ (Part 2 of 3 - Auto-Configure)
Microsoft Lync Server 2010 Installation
Oracle bi 10g_install_migration
Steps how to create active x using visual studio 2008
Forti gate troubleshooting_guide_v0.10
Power ai image-pipeline
Integrating Tomcat And Apache On Windows
Tomcat tutorail
Keycloak Single Sign-On

Recently uploaded (20)

PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
The influence of sentiment analysis in enhancing early warning system model f...
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Abstractive summarization using multilingual text-to-text transfer transforme...
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
Benefits of Physical activity for teenagers.pptx
PDF
Convolutional neural network based encoder-decoder for efficient real-time ob...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
The various Industrial Revolutions .pptx
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
Configure Apache Mutual Authentication
PDF
Five Habits of High-Impact Board Members
PDF
A comparative study of natural language inference in Swahili using monolingua...
DOCX
search engine optimization ppt fir known well about this
PDF
1 - Historical Antecedents, Social Consideration.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
A proposed approach for plagiarism detection in Myanmar Unicode text
Module 1.ppt Iot fundamentals and Architecture
The influence of sentiment analysis in enhancing early warning system model f...
Developing a website for English-speaking practice to English as a foreign la...
Abstractive summarization using multilingual text-to-text transfer transforme...
Chapter 5: Probability Theory and Statistics
Benefits of Physical activity for teenagers.pptx
Convolutional neural network based encoder-decoder for efficient real-time ob...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Custom Battery Pack Design Considerations for Performance and Safety
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
The various Industrial Revolutions .pptx
Hindi spoken digit analysis for native and non-native speakers
sbt 2.0: go big (Scala Days 2025 edition)
Configure Apache Mutual Authentication
Five Habits of High-Impact Board Members
A comparative study of natural language inference in Swahili using monolingua...
search engine optimization ppt fir known well about this
1 - Historical Antecedents, Social Consideration.pdf

web services using java

  • 1. 國立台灣科技大學 – 資訊管理 – IDSL 2014 Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan
  • 2. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 2 1. Table of Contents 1. TABLE OF CONTENTS ................................................................................ 2 2. DEVELOPMENT TOOLS ................................................................................ 3 2.1 DEVELOPMENT ENVIRONMENT .......................................................................... 3 2.2 TOMCAT INSTALLATION .................................................................................... 3 2.3 CONFIGURING FIREWALL ................................................................................... 9 2.4 AXIS2 INSTALLATION ...................................................................................... 14 2.5 INSTALL THE NECESSARY JAR FILES ............................................................... 19 2.6 SETTING UP ECLIPSE ....................................................................................... 20 3. BUILD A WEB SERVICE PROGRAM ........................................................ 23 3.1 CREATE A NEW PROJECT .................................................................................. 23 3.2 CREATE JAVA CLASS ....................................................................................... 26 3.3 CREATE A SERVER ........................................................................................... 28 3.4 STARTING WEB SERVICES ............................................................................... 31
  • 3. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 3 2. Development Tools Service:  Tomcat (http://tomcat.apache.org/) Web service deployment and development engine:  Apache Axis2 (http://axis.apache.org/axis2/java/core/)  Codehaus XFire (http://xfire.codehaus.org/)  Apache CXF (http://cxf.apache.org/)  JWSDP (Java Web Services Developer Pack) IDE:  Eclipse (http://www.eclipse.org/) 2.1 Development environment Software version:  Tomcat v7.0.42  Apache Axis2 v1.6.2  Eclipse Java EE IDE for Web Developers 2.2 Tomcat installation Download stable version of tomcat from http://tomcat.apache.org. In this document we will use Apache Tomcat v7.0.42 and it can be downloaded from http://tomcat.apache.org/download-70.cgi, it can be seen on Figure 1. Choose 32- bit/64-bit Windows Service installer to download apache-tomcat-7.0.42.exe. Figure 1. Apache Tomcat download page
  • 4. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 4 Follow these steps below to install and configure Apache Tomcat: 1. Run the Apache Tomcat’s installer and accept the installation agreement as seen in Figure 2 and Figure 3. Figure 2. Apache Tomcat’s installation setup wizard Figure 3. Apache Tomcat’s license agreement
  • 5. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 5 2. When asked about installation type, choose Normal. (see Figure 4. for the detailed information) Figure 4. Apache Tomcat’s installation type 3. Configure your Apache Tomcat’s installation. Set up your account’s User Name and Password in the corresponding field. (see Figure 5. for the detailed information) Figure 5. Apache Tomcat Setup: Configuration Options
  • 6. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 6 4. Select the path of Java SE or JRE installed on your computer. (see Figure 6. for the detailed information) Figure 6. Apache Tomcat Setup: Java Virtual Machine path selection 5. Choose the destination folder to install the Apache Tomcat. (see Figure 7. for the detailed information) Figure 7. Apache Tomcat’s destination folder
  • 7. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 7 6. After choosing the Apache Tomcat’s installation folder, wait for the installation setup to finish its process. After the installation has finished, the setup wizard will looks like Figure 8. Figure 8. Finished installation Apache Tomcat 7. To start Apache Tomcat, open up its configuration by: (WinKey)Start > All Programs > Apache Tomcat 7.0 Tomcat7 > Configure Tomcat ↵. Then, when it displays window such as in Figure 9, press the Start button. Figure 9. Apache Tomcat 7.0 configuration window
  • 8. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 8 8. When Apache Tomcat first running on your system, usually it will display a pop- up confirmation window asking permission for a program (Apache Tomcat) to communicate through your computer’s firewall. Allow this program to communicate through your firewall. 9. Open up your browser and go to http://localhost:8080. It will display a webpage which is located in the install location that have been selected before. In our case, the directory of the webpage would be in “C:Program FilesApache Software FoundationTomcat 7.0webappsROOT” (see Figure 10.) Figure 10. Default Webpage display of Apache Tomcat
  • 9. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 9 2.3 Configuring firewall After Apache Tomcat’s installation, make sure that port 8080 (default port used by Apache Tomcat) has been enabled on your computer. To activate port 8080 through your computer’s firewall, follow these steps: 1. Open up Windows Control Panel through Start Menu (see Figure 11.). Figure 11. Open Start menu and select Control Panel 2. On control panel window under the category of System and Security, choose Windows Firewall (see Figure 12). Figure 12. Select Windows Firewall on Windows’ System and Security window
  • 10. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 10 3. On windows firewall’s window, choose “Advanced settings” from the sidebar (see Figure 13). Figure 13. Choose “Advanced settings” on Windows firewall sidebar 4. On windows firewall advance settings’ window, click on “Inbound Rules” and then click on “New rule…” to add new rule that will allow Apache Tomcat to use port 8080 through Windows Firewall (see Figure 14). Figure 14. Add new inbound rule into windows firewall 5. In the New Inbound Rule Wizard, choose Port as the rule type and then press button “Next” (see Figure 15).
  • 11. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 11 Figure 15. Select “Port” as the rule type in New Inbound Rule Wizard 6. Select “TCP” as the protocol and input “8080” as the port number (see Figure 16). Figure 16. Select “TCP” as the protocol type and “8080” as the port number
  • 12. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 12 7. Select “Allow the connection” as the action to be taken (see Figure 17). Figure 17. Choose “Allow the connection” on the action selection 8. Check on all options in the profile section (see Figure 18). Figure 18. Check all options in the profile section
  • 13. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 13 9. Give a name on the newly created inbound rule in the corresponding field, in this example: tomcat (see Figure 19). After giving a name to the new inbound rule, press button “Finish” to complete the process. Figure 19. Give a name to the newly created inbound rule
  • 14. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 14 2.4 Axis2 installation Download stable version of Apache Axis2 from http://axis.apache.org/axis2/java/core/download.cgi. In this document we will use Apache Axis2 v1.6.2. Download binary distribution of the Apache Axis2 v1.6.2 (http://apache.cdpa.nsysu.edu.tw//axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip). Follow these steps below to configure Apache Axis2: 10. After downloading axis2-1.6.2-bin.zip, extract the file to C:axis2-1.6.2. 11. Open up your computer properties and then select “Advanced system settings” from the sidebar menu (see Figure 20). Figure 20. Open computer’s properties and select “Advanced system settings” 12. On the advanced system settings window, click on the button “Environment Variables…” as seen on Figure 21. Figure 21. Click button “Environment Variables…” on the advanced system properties window
  • 15. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 15 13. On the environment variable window, add a new system variables by clicking button “New…” (see Figure 22). Figure 22. Add new system variables 14. On the new system variable window, set the variable name as “AXIS2_HOME” and variable value as the directory of the extracted Apache Axis2 file (C:axis2- 1.6.2). After finish setting up the new system variable, click button “OK” (see Figure 23). Figure 23. New Apache Axis2 system variable
  • 16. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 16 15. Download axis2-1.6.2-war.zip from http://ftp.mirror.tw/pub/apache//axis/axis2/java/core/1.6.2/axis2-1.6.2-war.zip and extract the downloaded file to any directory. 16. Open your browser and go to http://localhost:8080/ and then click on “Manager App” button (see Figure 24). Figure 24. Click on “Manager App” button on the Apache Tomcat page 17. On Tomcat Web Application Manager’s page, upload the extracted file axis2.war by clicking on button “Choose File” under the “Deploy” group. After selecting the file to be uploaded, click on the “Deploy” button (see Figure 25). Figure 25. Deploy the Web application ARchive (WAR) file
  • 17. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 17 18. If the Web application ARchive (WAR) file has been successfully deployed, it will be displayed under the list of Applications (see Figure 26). Figure 26. Successfully uploaded and deployed WAR file 19. After axis2 has been deployed, go to http://localhost:8080/axis2/ on the new tab of your browser, and it will display a page such as in Figure 27. Figure 27. Successfully deployed axis2 web application
  • 18. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 18 On the axis2 homepage, there are three (3) available links: Link Function Services View the list of all the available services deployed in this server. Validate Check the system to see whether all the required libraries are in place and view the system information. Administration Console for administering Axis2 installation. Axis2 provide one user account by default. User Name : admin Password : axis2 20. To change the default User Name and Password, go to Apache Tomcat installation directory (C:Program FilesApache Software FoundationTomcat 7.0webappsaxis2WEB-INFconf). Open axis2.xml file and look for the following line: <parameter name="userName">admin</parameter> <parameter name="password">axis2</parameter> Edit the parameter value and do not forget to save the file after you finished editing.
  • 19. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 19 2.5 Install the necessary JAR files Open up your browser and go to http://www.java2s.com/Code/Jar/CatalogJar.htm. Download activation.jar, mail.jar, tools.jar, xmlsec.jar and put it insides lib folder in your Apache Tomcat installation folder (see Figure 28). For example: C:Program FilesApache Software FoundationTomcat 7.0lib. Figure 28. Store activation.jar, mail.jar, tools.jar, and xmlsec.jar inside lib folder Copy all files inside C:axis2-1.6.2lib to C:Program FilesApache Software FoundationTomcat 7.0lib.
  • 20. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 20 2.6 Setting up Eclipse Follow these steps below to configure eclipse: 1. Open Eclipse. 2. On the menu bar, select Window  Preferences. 3. Select Server  Runtime Environments  Add. 4. On the New Server Runtime Environment, choose Apache Tomcat v7.0 and then press button “Next” (see Figure 29). Figure 29. Choose Apache Tomcat v7.0 as the new server runtime environment 5. Assign the Tomcat installation directory and then press button “Finish” (see Figure 30).
  • 21. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 21 Figure 30. Assign Apache Tomcat installation directory into eclipse 6. Back to eclipse’s preferences window, now select Web Services  Axis2 Preferences. Set Axis2 runtime location with the directory of extracted axis2- 1.6.2 in your computer, e.g. C:axis2-1.6.2 (see Figure 31). Figure 31. Assign Axis2 runtime location
  • 22. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 22 7. Back on the Web Services, now select Server and Runtime. Change the value of Web service runtime from Apache Axis to Apache Axis2 (see Figure 32). Figure 32. Change the value of Web service runtime to Apache Axis2
  • 23. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 23 3. Build a Web Service Program This part will describe the process to create a web service program. 3.1 Create a new project Follow these steps below to create a new project for the web service program: 1. Create a new project for the web service program by selecting “File  New  Other  Web  Dynamic Web Project” on the Eclipse menu bar (see Figure 33). After selecting to create a dynamic web project, click on the “Next” button. Figure 33. Create new dynamic web project in Eclipse 2. Fill in the project name (e.g. idsl-web-service) and set the dynamic web module version to version 2.5 (see Figure 34).
  • 24. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 24 Figure 34. Configure the new web service project 3. Click on “Modify” button to set project configuration (see Figure 34). On the project configuration window, check “Axis2 Web Services” option and then press button “OK” (see Figure 35). 4. After finish adding “Axis2 Web Services” on the project configuration, click button “Finish” to create the project.
  • 25. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 25 Figure 35. Check “Axis2 Web Services” on the project configuration window
  • 26. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 26 3.2 Create Java class Follow these steps below to create Java class for your web service project: 1. Right click on the web service project and then on the pop-up menu select “New  Class” (see Figure 36). Figure 36. Create new Java class inside the web service project 2. Assign a name (e.g. HelloWorld) for the new Java class to be created then click on button “Finish” to create the class (see Figure 37). 3. Try to put some code into the created class (see Figure 38).
  • 27. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 27 Figure 37. Create HelloWorld class Figure 38. Try put on some code into HelloWorld class
  • 28. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 28 3.3 Create a server To create a server, follow these steps below: 1. There are two ways to create a server, via Eclipse’s menu bar or Eclipse’s Servers page. The first way to create server is by selecting “File  New  Other…” on Eclipse’s menu bar. Then choose “Server” from the list as shown in Figure 39. Figure 39. Create new server from Eclipse menu bar Another way to do this is via Eclipse’s Servers window. Right click on Eclipse Servers’ page and then choose “New  Server” from pop-up menu as shown in Figure 40. In case Eclipse’s Servers page is not displayed, select “Window  Show View  Servers” from the menu bar. Figure 40. Create new server from Eclipse Server window
  • 29. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 29 2. Choose “Tomcat v7.0 Server” from the list of server type and then click button “Finish” (see Figure 41). Figure 41. Create new Tomcat v7.0 server 3. In the Servers page, double click on the server that you have just created to open up the general information about the server. Then change the server locations to “Use Tomcat Installation (takes control of Tomcat installation)” (see Figure 42).
  • 30. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 30 Figure 42. Change the server location to “use tomcat installation”
  • 31. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 31 3.4 Starting Web Services To start the web service, expand the Eclipse project explorer and look for class java file that has been created (e.g. HelloWorld.java). Right click on that file and from the pop-up menu choose “Web Services  Create Web Service” as shown in Figure 43. Figure 43. Create web service for HelloWorld.java Check the created web service’s configuration and make sure that the “Web service runtime” is set to “Apache Axis2” as shown in Figure 44, then click on button “Next”. If the “Web service runtime” is not set to “Apache Axis2”, then change its value by clicking on the web service runtime’s link and change its value to Apache Axis2 as shown in Figure 45.
  • 32. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 32 Figure 44. Make sure that web service runtime is set to Apache Axis2 Figure 45. Choose Apache Axis2 as the web service runtime
  • 33. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 33 After clicking button “Next”, do not forget to choose “Generate a default services.xml file” as shown in Figure 46. Figure 46. Generate a default services.xml file After clicking on “Finish” button, do not forget to start the Tomcat server by clicking “Start server” button (see Figure 47). Figure 47. Click on button “Start server” to start the Tomcat server
  • 34. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 34 After starting the Tomcat server, open up your browser and go to http://localhost:8080/<your-web-service-project-name>. In this tutorial the address would be http://localhost:8080/idsl-web-service/ (see Figure 48). Click on the “Services” link to see all available services run on the server. In this tutorial you will see the HelloWorld Web service as shown in Figure 49. Figure 48. The display of idsl-web-service Figure 49. The display of all available services on idsl-web-service
  • 35. Web Services Using Java Tomcat + Axis2 + Eclipse 羅乃維, Alexander Yohan 國立台灣科技大學 – 資訊管理 – IDSL | 台北市大安區基隆路 4 段 43 號 35 Try clicking on the HelloWorld web service to make it shows the WSDL as shown in Figure 50. Figure 50. HelloWorld web service’s WSDL Use RESTful to test the return value from the code in file HelloWorld.java. In your browser go to http://localhost:8080/<your-web-service-project- name>/services/<service-name>/<function-name>?<parameter- name>=<parameter-value>. In this tutorial, the address would be: http://localhost:8080/idsl-web- service/services/HelloWorld/printName?name=Alexander. (see Figure 51) Figure 51. Use RESTful to test the return value