批量安裝部署web service到axis server

批量安裝部署web service到axis server

環境:
先取的如下軟件:
1.tomcat 5.0.28
2.axis-1_2alpha.zip

將axis-1_2alpha.zip解壓到d:/目錄,將裏面的webapps下的axis整個目錄copy到tomcat的webapps下。
重起tomcat後在地址欄輸入http://localhost:8080/axis/可以看到
如下畫面就說明axis app 部署成功:

Apache-AXIS

Hello! Welcome to Apache-Axis.

What do you want to do today?

  • Validate the local installation's configuration
    see below if this does not work.
  • View the list of deployed Web services
  • Call a local endpoint that list's the caller's http headers (or see its WSDL).
  • Visit the Apache-Axis Home Page
  • Administer Axis
    [disabled by default for security reasons]
  • SOAPMonitor
    [disabled by default for security reasons]

To enable the disabled features, uncomment the appropriate declarations in WEB-INF/web.xml in the webapplication and restart it.

Validating Axis

If the "happyaxis" validation page displays an exception instead of a status page, the likely cause is that you have multiple XML parsers in your classpath. Clean up your classpath by eliminating extraneous parsers.

If you have problems getting Axis to work, consult the Axis Wiki and then try the Axis user mailing list.




然後點擊
Validate,校驗是否axis可以工作
如果出錯的話會提示你少那些包,並提示到那裏取得這些包,這些包分爲兩類core(核心)和option(可選)
本人少了一個和core lib和2個option
core:
activation.jar

option:
xmlsec.jar
mail.jar

上網取得這些包放到axis app的lib下或tomcat 的common/lib下重起tomcat就可以看到axis可以正常工作的提示。

設置環境變量:
做爲學習,可以自己寫一個setpath.bat的文件,設置好axis的axisclasspath:
本人的axis解壓到d:/axis目錄下,所以setpath文件如下:
setpath.bat

set AXIS_HOME=D:/axis
set AXIS_LIB=%AXIS_HOME%/lib
set AXISCLASSPATH=%AXIS_LIB%/axis.jar;%AXIS_LIB%/commons-discovery.jar;%AXIS_LIB%/commons-logging.jar;%AXIS_LIB%/jaxrpc.jar;%AXIS_LIB%/saaj.jar;%AXIS_LIB%/log4j-1.2.8.jar;%AXIS_LIB%/xml-apis.jar;%AXIS_LIB%/xercesImpl.jar


注意第一行和和第二行的後面都應該沒有空格,否則會導致AXISCLASSPATH錯誤;執行改bat

部署webservice:

我們要部署爲webservic的文件在d:/axis/samples下,現在我們部署該目錄下的stock目錄下面的application

在確保你的tomcat已經啓動,並且你的axis app 已經在http://localhost:8080/axis/

進到d:/axis/samples/stock目錄下
執行如下代碼:

java -cp %AXISCLASSPATH% org.apache.axis.client.AdminClient -lhttp://localhost:8080/axis/services/AdminService deploy.wsdd

如果期間出現classnotfind之類的錯誤,檢查你的環境變量有沒有錯(通常會有一些空格,或者打錯字的錯誤)
如果提示connect refuse,則是tomcat沒啓動,或http://localhost:8080/axis/services/AdminService 不能工作

部署成功的話,查看{axis app}/web-inf 下多了一個文件server-config.wsdd,這個文件是web service的deploy desciptor.

測試部署成功的web service:

回到AXIS_HOME目錄下,執行:
java -cp .;%AXISCLASSPATH% samples.stock.GetQuote -lhttp://localhost:8080/axis/servlet/AxisServlet -uuser1 -wpass1 XXX

見結果如下:

D:/axis>java -cp .;%AXISCLASSPATH% samples.stock.GetQuote -lhttp://localhost:808
0/axis/servlet/AxisServlet -uuser1 -wpass1 XXX
log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectR
esourceBundle).
log4j:WARN Please initialize the log4j system properly.
XXX: 55.25

測試通過cake.gif



下面是將axis集成到你自己的app裏

  1. Advanced Installation: adding Axis to your own Webapp

    If you are experienced in web application development, and especially if you wish to add web services to an existing or complex webapp, you can take an alternate approach to running Axis. Instead of adding your classes to the Axis webapp, you can add Axis to your application.

    The core concepts are

    1. Add axis.jar, wsdl.jar, saaj.jar, jaxrpc.jar and the other dependent libraries to your WAR file.
    2. Copy all the Axis Servlet declarations and mappings from axis/WEB-INF/web.xml and add them to your own web.xml
    3. Build and deploy your webapp.
    4. Run the Axis AdminClient against your own webapp, instead of Axis, by changing the URL you invoke it with.

    The process is also covered in Chapter 15 of Java Development with Ant, which can be downloaded as a PDF file.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章