Java – Tomcat + Axis2 架設 Web Service

使用 Java 在開發 Web Project 至今並沒有寫過任何 Java 版的 Web Service,不過還是要做個小小的 example 記錄如何在 Tomcat 下開發 Web Service .在此使用 apache 下提個的 axis2 project 來架設 Web Service.

1. 首先從 Apache Axis2 Web 下載最新版的 Binary Distribution,解壓至存放的 Folder 中.

2. Eclipse 中設定 Tomcat Server 的 Runtime Environment

image

再來是 Web Services 的部份.

image

3. Create new dynamic web project.

image

4. 寫一個一般的 Java Class,此部份的範例是使用 HelloWorld 做為 Sample.

image

6. 在所需的提供 Web Service 的 Class 上按右鍵選取Web Service –> Create Web Service

image

按下 “configuration” 選取相對映的 Tomcat 及 Axis2

image

之後按下 Finish 鈕後已完成 Tomcat + Axis2 架設 Web Service.使用 Web Browser 上輸入 http://localhost:8080/TestWebWervice 後即可看到的畫面如下所示:

image

PS : 如未有上面的畫面時,請查看 web.xml 上其 welcome-file-list 中是否有加入 <welcome-file>/axis2-web/index.jsp</welcome-file>

image

留言

這個網誌中的熱門文章

WPF - 深入 Style

C# – M$ Chart Control 自定 ToolTip 的顯示

Vue.js - 基礎介紹教學