参考文档
http://www.cnblogs.com/hoojo/archive/2010/12/20/1911349.html
http://www.ibm.com/developerworks/cn/webservices/ws-axisfaq/index.html
http://mljavalife.iteye.com/blog/1182063
下载 axis-1.2.zip 文件并解压。设置axis的环境变量 "AXIS_HOME"
服务端
① 根据给定wsdl 生成axis1服务端命令:
-
java -Djava.ext.dirs=%AXIS_HOME%\lib org.apache.axis.wsdl.WSDL2Java <wsdl地址> -o <%Output_Path%> -d Session -s -S true -p <%Package%>
将java的方法,用axis1.4的命令生成WSDL文件命令java2wsdl.bat
-
set Axis_Lib=E:\apache-tomcat-6.0.32\webapps\axis\WEB-INF\lib
-
set Java_Cmd=java -Djava.ext.dirs=%Axis_Lib%
-
%Java_Cmd% org.apache.axis.wsdl.Java2WSDL -o HelloImpl.wsdl -l "" -n "urn:HelloImpl" -p"axis.wsdd" "urn:HelloImpl444444" axis.wsdd.HelloImpl
-
pause;
web.xml 加入如下代码
-
<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-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>AdminServlet</servlet-name>
-
<url-pattern>/servlet/AdminServlet</url-pattern>
-
</servlet-mapping>
WebService部署 (
需要服务器上先启动WEB应用)
利用deploy.wsdd 自动部属生成 server-config.wsdd 配置文件 命令
-
java -Djava.ext.dirs=%AXIS_HOME%\lib org.apache.axis.client.AdminClient deploy.wsdd -l services/AdminService
把服务器上生成的
server-config.wsdd 拷贝下来
最后WEB工程(axis1服务端) 目录结构如下:
-
WebContent
-
|-- WEB-INF
-
|-- classes
-
|-- lib 添加 axis1 的jar包
-
|-- server-config.wsdd 描述文件 利用deploy.wsdd生成
-
|-- web.xml
监听WebService命令
-
java -Djava.ext.dirs=%AXIS_HOME%\lib org.apache.axis.utils.tcpmon
axis1.4生成客户端命令:
-
java -Djava.ext.dirs=%AXIS_HOME%\lib org.apache.axis.wsdl.WSDL2Java -o <%Output_Path%> -p <%Package%>
客户端调用示例 :
-
/**
-
* axis1 方式 webservice 客户端
-
* BusinessService SoapBindingStub 引用时,必须判断null,为null表示Webservice获取失败
-
*
-
* @return
-
*/
-
public BusinessService getBusinessService() {
-
if (businessService == null) {
-
String wsdlUrl = "Business/BusinessService?wsdl";
-
BusinessServiceServiceLocator locator = new BusinessServiceServiceLocator();
-
try {
-
businessService = locator.getBusinessService(new java.net.URL(wsdlUrl));
-
} catch (MalformedURLException e) {
-
e.printStackTrace();
-
} catch (ServiceException e) {
-
e.printStackTrace();
-
}
-
}
-
return businessService;
-
}
问题总结:
运行的时候,有 警告,错误 如下:
org.apache.axis.utils.JavaUtils isAttachmentSupported
- Unable to find required classes (javax.activation.DataHandler and javax.mail.i
nternet.MimeMultipart). Attachment support is disabled.
解决办法:
将“activation.jar”和“mail.jar”包拷贝到lib。
阅读(2893) | 评论(0) | 转发(0) |