一、部署AXIS
1、从AXIS官网上下载axis-1_4的发行版,解压到特定路径下(例如:“E:”)
2、从java官网上查找并下载mail.jar及activation.jar,官网上找不到的话,可以考虑从百度上搜索后下载
3、添加环境变量(假定解压到“E:”):
(1)变量名:AXIS_LIB
变量值:E:axis-1_4lib
(2)变量名:CLASSPATH
变量值:.;%JAVA_HOME%lib;%CATALINA_HOME%lib;%AXIS_LIB%axis.jar;%AXIS_LIB%axis-ant.jar;%AXIS_LIB%commons-discovery-0.2.jar;%AXIS_LIB%commons-logging-1.0.4.jar;%AXIS_LIB%jaxrpc.jar;%AXIS_LIB%log4j-1.2.8.jar;%AXIS_LIB%saaj.jar;%AXIS_LIB%wsdl4j-1.5.1.jar;%AXIS_LIB%activation.jar;%AXIS_LIB%mail.jar
注:以下假定(1)axis解压到“E:”目录下;(2)给定的ServerActionSV.wsdl存放于“E:protocols”目录下
二、有wsdl的情况
1、打开“开始->运行”,输入“cmd”,进入命令行窗口
2、在命令行窗口下,依次输入“E:”、“cd E:axis-1_4lib”
3、输入“E:axis-1_4lib>java org.apache.axis.wsdl.WSDL2Java "E:protocols/ServerActionSV.wsdl"”,
执行完成后,将在“E:axis-1_4lib”目录下生成Java代码,例如:“E:axis-1_4libcncommbossvsopwwwvsop”
目录下的VsopServiceRequest.java、ServerActionSV_Service.java等等。
(如果没有进入指定的目录,将会提示没有找到WSDL2Java错误)。
4、生成的Java代码有很多,但大部分都不用管,只需打开“ServerActionSV_BindingImpl.java”,实现给定的方法即可
5、启动MyEclipse,新建一个WebService工程(假定命名为newWebService),加入“E:axis-1_4lib”中的所有lib、根
据wsdl生成的所有代码及生成的deploy.wsdd(注意命名空间,如果命名空间改动的话,也要对deploy.wsdd进行修改)
6、在Web.xml中添加Servlet(见文档最后)
7、部署newWebService
8、在7令行中进入“E:axis-1_4libcncommbossvsopwwwvsop>”目录,输入“E:axis-1_4libcncommbossvsopwwwvsop>java org.apache.axis.client.AdminClient -l http://localhost:8080/newWebService/servlet/AxisServlet deploy.wsdd”(其中的监听端口与newWebService根据实际情况作修改)
附:web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<listener>
<listener-class>
org.apache.axis.transport.http.AxisHTTPSessionListener
</listener-class>
</listener>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
</servlet-class>
</servlet>
<servlet>
<servlet-name>AdminServlet</servlet-name>
<display-name>Axis Admin Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AdminServlet
</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet>
<servlet-name>SOAPMonitorService</servlet-name>
<display-name>SOAPMonitorService</display-name>
<servlet-class>
org.apache.axis.monitor.SOAPMonitorService
</servlet-class>
<init-param>
<param-name>SOAPMonitorPort</param-name>
<param-value>5001</param-value>
</init-param>
<load-on-startup>100</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SOAPMonitorService</servlet-name>
<url-pattern>/SOAPMonitor</url-pattern>
</servlet-mapping>
<session-config>
<!-- Default to 5 minute session timeouts -->
<session-timeout>5</session-timeout>
</session-config>
<!-- currently the W3C havent settled on a media type for WSDL; http://www.w3.org/TR/2003/WD-wsdl12-20030303/#ietf-draft
for now we go with the basic 'it's XML' response -->
<mime-mapping>
<extension>wsdl</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<mime-mapping>
<extension>xsd</extension>
<mime-type>text/xml</mime-type>
</mime-mapping>
<welcome-file-list id="WelcomeFileList">
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>