axis2 入門 quickstart(webservice Requested resource not found)
axis2入門最多的人應(yīng)該是從axis2的官方教程中的quickstart開始,但是axis2的官方教程中存在著一個(gè)小小的錯(cuò)誤,本文詳細(xì)謝謝這個(gè)錯(cuò)誤的產(chǎn)生及原因。對(duì)于細(xì)節(jié)的操作因?yàn)橄逻呌泄俜郊胺g的版本,我不再細(xì)說
官方quickstart doc url
http://ws.apache.org/axis2/1_1_1/quickstartguide.html#introduction
http://hideto.javaeye.com/blog/56835
按照教程中講解的,放好war包,編譯完成例子,把StockQuoteService.aar拷貝到webapps\axis2\WEB-INF\services下,后臺(tái)出現(xiàn)部署成功的提示。
按照教程依次訪問
http://localhost:8080/axis2/services/listServices
http://localhost:8080/axis2/services/StockQuoteService?wsdl
http://localhost:8080/axis2/services/StockQuoteService?xsd
http://localhost:8080/axis2/rest/StockQuoteService/getPrice?symbol=IBM
前三個(gè)都能成功,但是最后一個(gè)訪問的時(shí)候一直會(huì)報(bào)錯(cuò)誤,頁面提示“Requested resource not found”
試試下邊的
http://localhost:8080/axis2/rest/StockQuoteService/update?symbol=IBM&price=100
一樣的錯(cuò)誤,什么原因呢?
最開始想到的是打開debug看看,結(jié)果如下:
1
[DEBUG] Start expire sessions StandardManager at 1233371524421 sessioncount 1
2
[DEBUG] End expire sessions StandardManager processingTime 0 expired sessions: 0
3
[DEBUG] servletPath=/axis2-web/Error/error404.jsp, pathInfo=null, queryString=null, name=null
4
[DEBUG] Path Based Forward
5
[DEBUG] JspEngine --> /axis2-web/Error/error404.jsp
6
[DEBUG] ServletPath: /axis2-web/Error/error404.jsp
7
[DEBUG] PathInfo: null
8
[DEBUG] RealPath: D:\appserver\apache-tomcat-5.5.25\webapps\axis2\axis2-web\Error\error404.jsp
9
[DEBUG] RequestURI: /axis2/axis2-web/Error/error404.jsp
10
[DEBUG] QueryString: symbol=IBM
11
[DEBUG] Request Params:
12
[DEBUG] symbol = IBM
13
[DEBUG] servletPath=/axis2-web/include/httpbase.jsp, pathInfo=null, queryString=null, name=null
14
[DEBUG] Path Based Include
15
[DEBUG] JspEngine --> /axis2-web/include/httpbase.jsp
16
[DEBUG] ServletPath: /axis2-web/Error/error404.jsp
17
[DEBUG] PathInfo: null
18
[DEBUG] RealPath: D:\appserver\apache-tomcat-5.5.25\webapps\axis2\axis2-web\include\httpbase.jsp
19
[DEBUG] RequestURI: /axis2/axis2-web/Error/error404.jsp
20
[DEBUG] QueryString: symbol=IBM
21
[DEBUG] Request Params:
22
[DEBUG] symbol = IBM
23
[DEBUG] Disabling the response for futher output
24
看到原因是404錯(cuò)誤,這個(gè)錯(cuò)誤太常見了,想想什么原因?先看看axis2 war包的結(jié)構(gòu)吧,第一個(gè)當(dāng)然是web.xml打開看了一遍,有個(gè)印象,然后在看看,沒有用什么框架,那關(guān)鍵還是web.xml,仔細(xì)看這段
2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

1
<servlet-mapping>
2
<servlet-name>AxisServlet</servlet-name>
3
<url-pattern>/servlet/AxisServlet</url-pattern>
4
</servlet-mapping>
5
6
<servlet-mapping>
7
<servlet-name>AxisServlet</servlet-name>
8
<url-pattern>*.jws</url-pattern>
9
</servlet-mapping>
10
11
<servlet-mapping>
12
<servlet-name>AxisServlet</servlet-name>
13
<url-pattern>/services/*</url-pattern>
14
</servlet-mapping>
說明大部分的處理都是通過AxisServlet來轉(zhuǎn)發(fā)的,而這個(gè)servlet只過濾以上三種情況,那么是不是官方文檔錯(cuò)誤呢?是不是第四個(gè)訪問也需要讓AxisServlet來處理呢?試試吧,把http://localhost:8080/axis2/rest/StockQuoteService/getPrice?symbol=IBM改成
2

3

4

5

6

7

8

9

10

11

12

13

14

http://localhost:8080/axis2/services/StockQuoteService/getPrice?symbol=IBM
訪問,成功返回需要的值,問題解決。webservice因?yàn)榉庋b的多,所以debug困難,一個(gè)小問題都要忙活半天,還是以猜測(cè)為主,呵呵。
另外補(bǔ)充一個(gè)小tips,只要以“爆炸”方式部署webservice,就是不打aar 包,就能debug pojo中的代碼了。
posted on 2009-01-31 11:20 dreamstone 閱讀(3878) 評(píng)論(0) 編輯 收藏 所屬分類: 其它開源框架