在自己的工程里发布webservice的步骤
1. 下载axis-bin-1_4,解压
2. 新建web项目MyWebServices,把解压后文件夹axis-1_4\\webapps\\axis\\WEB-INF\\lib下
的8个jar包拷贝到该项目的WebRoot\\WEB-INF\\lib下。
3. 修改该项目的web.xml文件加入axis监听器还有servlet的相关配置:
示例代码:
org.apache.axis.transport.http.AxisServlet
org.apache.axis.transport.http.AdminServlet
org.apache.axis.monitor.SOAPMonitorService
4. 在自己的项目中创建一个最基本的业务类:
(这里编写了一简单业务:输入参数:String,返回数据:String。) 示例代码:
public class SayHello { }
public String hello(String name){
return \你好,\+name+\欢迎你.\; }
5. 在web.xml下编写server-config.wsdd文件发布该业务为webservices
示例代码:
xmlns:java=\ xmlns:handler=\xmlns=\> type=\> type=\> type=\/> type=\/> type=\/> type=\/>
说明:第一行指明了该webservices的服务名和服务类型(rpc);
第二行是配置了services的scope,主要有Request,Session,Application三种 第三行是配置了webservices所对应的class
第四行是配置了该webservices所允许调用的方法,“*”表示所有的pubic方法都可供调用
6. 把项目发布到tomcat上,下面我们调用一下。
打开浏览器,在地址栏输入http://127.0.0.1:8080/MyWebServices/services 你会看到如下界面:
这就表示webservices发布成功了,单击wsdl查看一下对于该webservices的描述: http://127.0.0.1:8080/MyWebServices/services/SayHello?wsdl:
ello\
targetNamespace=\http://127.0.0.1:8080/MyWebServices/services/SayH xmlns:apachesoap=\http://xml.apache.org/xml-soap\ xmlns:impl=\http://127.0.0.1:8080/MyWebServices/services/SayHello\ xmlns:intf=\http://127.0.0.1:8080/MyWebServices/services/SayHello\ xmlns:soapenc=\http://schemas.xmlsoap.org/soap/encoding/\ xmlns:wsdl=\http://schemas.xmlsoap.org/wsdl/\ xmlns:wsdlsoap=\http://schemas.xmlsoap.org/wsdl/soap/\ xmlns:xsd=\http://www.w3.org/2001/XMLSchema\ - - - - - - transport=\http://schemas.xmlsoap.org/soap/http\ - style=\rpc\