java webservice的多种实现方法汇总
一、基于EJB容器管理webservice :
1.首先建立一个Web services EndPoint:
package cn.test.service.impl; import java.util.ArrayList; import java.util.List; import javax.jws.WebMethod; import javax.jws.WebService; import cn.test.Person; import cn.test.service.HelloWorld; @WebService public class HelloWorldImpl implements HelloWorld { @WebMethod public void say() { System.out.println(" hello service"); } @WebMethod public Person getPersonById( String id) { System.out.println(" id = "+id); return new Person("aaa", "123", 5); } @WebMethod public List<Person> getAll() { List<Person> list = new ArrayList<Person>(); for (int i = 0; i < 5; i++) { list.add(new Person("100"+i, "kk"+i, 12+i)); } return list; } @WebMethod public String insert(Person p) { System.out.println(p); return p.getId()+"java"; } }
2. 进入src目录下使用 apt 编译 Hello.java(例:apt -d [存放编译后的文件目录] Hello.java ) ,会生成 jaws目录。例如:D:\dianzi\Test\src>apt -d . cn/test/service/impl/HelloWorldImpl.java
3.使用java Hello.Hello运行,然后将浏览器指向http://localhost:8080/hello?wsdl就会出现下列显示
4.使用wsimport 生成客户端
使用如下:D:\dianzi\Test\src>wsimport -p cn.client -keep http://localhost:8080/helloWorld?wsdl
这时,会在当前目录中生成如下文件:
5.客户端测试:
public class T { public static void main(String[] args) { HelloWorldImplService service = new HelloWorldImplService(); HelloWorldImpl helloWorld = (HelloWorldImpl) service.getHelloWorldImplPort(); System.out.println(helloWorld.getAll().size()); System.out.println(helloWorld.getPersonById("")); } }
6、不用生成代码,通过jboss服务器进行管理:
例如下面的类写好之后,发布到服务器上,通过地址 http://127.0.0.1/root/CompanyService?wsdl 就可以查看发布情况,其中“contextRoot”表示根目录,urlPattern表示匹配路径。
@Stateless @WebService @WebContext(contextRoot = "/root", urlPattern = "/CompanyService") @SOAPBinding(style = SOAPBinding.Style.RPC,use=SOAPBinding.Use.LITERAL, parameterStyle=SOAPBinding.ParameterStyle.WRAPPED) public class CompanyWSBean implements CompanyWS { Logger logger=Logger.getLogger(CompanyWSBean.class); @EJB private CompanyServiceLocal companyServiceLocal; @WebMethod @WebResult(partName = "return") public TBLCompany find(String id) { try { return companyServiceLocal.find(id); } catch (Exception e) { logger.error(e); } return null; } }
二、将第一种webservice移动到 WEB层,就是通过WEB容器模式管理:
1、准备pojo对像:接口和实现类
开发步骤如下:
建立一个POJO端点--在web.xml中--------将这个POJO端点配置成一个Servlet-----------将这个POJO端点打包成一个应用(war包或ear)
package cn.test.ws.web.intf; import com.cjonline.foundation.evisa.entity.TBLOperator; public interface HelloWorld { public String say(String s); public String eat(String s); public TBLOperator findOperator(); }
package cn.test.ws.web.impl; import javax.jws.WebMethod; import javax.jws.WebService; import cn.test.ws.web.intf.HelloWorld; import com.cjonline.comm.util.EJBAssistant; import com.cjonline.foundation.evisa.entity.TBLOperator; import com.cjonline.foundation.evisa.exception.ServiceException; import com.cjonline.foundation.evisa.service.intf.OperatorServiceRemote; @WebService public class HelloWorldImpl implements HelloWorld{ private OperatorServiceRemote userService = EJBAssistant.getEJB( "OperatorServiceBean/remote", OperatorServiceRemote.class); @WebMethod public String say(String s) { System.out.println(" web say : "+ s); return " web say : "+s; } @WebMethod public String eat(String s) { System.out.println(" web eat : "+ s); return " web eat : "+s; } @WebMethod public TBLOperator findOperator(){ try { return userService.findAll1().get(0); } catch (ServiceException e) { e.printStackTrace(); } return null; } }
2、在web.xml中将它配置成一个Servlet:
<servlet> <servlet-name>HelloService</servlet-name> <servlet-class>cn.test.ws.web.impl.HelloWorldImpl</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloService</servlet-name> <url-pattern>/hello</url-pattern> </servlet-mapping>
3、进入到jbossws管理服务中,通过地址 http://lenovo-pc//hello?wsdl 可以查看发布的信息,就可以调用方法。
三、使用xfire,我这里使用的是myeclipse集成的xfire进行测试的:
利用xfire开发WebService,可以有三种方法:
1一种是从javabean 中生成;
2 一种是从wsdl文件中生成;
3 还有一种是自己建立webservice
步骤如下:
用myeclipse建立webservice工程,目录结构如下:
首先建立webservice接口,代码如下:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
接着实现这个借口:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
修改service.xml 文件,加入以下代码:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
把整个项目部署到tomcat服务器中 ,打开浏览器,输入http://localhost:8989/HelloWorld/services/HelloWorldService?wsdl,可以看到如下:
然后再展开HelloWorldService后面的wsdl可以看到:
客户端实现如下:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
13
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
14
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
15
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
16
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
17
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
18
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
19
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
20
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
21
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
22
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
23
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
24
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
25
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
26
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
27
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
29
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
30
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
31
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
32
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
33
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
34
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
35
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
这里再说点题外话,有时候我们知道一个wsdl地址,比如想用java客户端引用.net 做得webservice,使用myeclipse引用,但是却出现无法通过验证的错误,这时我们可以直接在类中引用,步骤如下:
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
13
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
15
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
四、使用axis1.4调用webservice方法
前提条件:下载axis1.4包和tomcat服务器 ,并将axis文件夹复制到tomcat服务器的webapp文件夹中
这里我就说一下最简单的方法:
首先建立一个任意的java类(例如:HelloWorld.java),复制到axis文件夹下,将其扩展名改为jws,然后重新启动tomcat,在浏览器中输入http://localhost:8989/axis/HelloWorld.jws?wsdl,就会得到一个wsdl文件,其客户端调用方法如下:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
13
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
14
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
16
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
17
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
18
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
19
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
20
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
21
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
22
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
23
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
24
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
25
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
26
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
27
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
29
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
30
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
五、使用axis2开发webservice
使用axis2 需要先下载
axis2-1.4.1-bin.zip
axis2-1.4.1-war.zip
http://ws.apache.org/axis2/
同理,也需要将axis2复制到webapp目录中
在axis2中部署webservice有两种方法,
第一种是pojo方式,这种方式比较简单,但是有一些限制,例如部署的类不能加上包名
第二种方式是利用xml发布webservice,这种方法比较灵活,不需要限制类的声明
下面分别说明使用方法:
1.pojo方式:在Axis2中不需要进行任何的配置,就可以直接将一个简单的POJO发布成WebService。其中POJO中所有的public方法将被发布成WebService方法。先实现一个pojo类:
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
由于这两个方法都是public类型,所以都会发布成webservice。编译HelloWorld类后,将HelloWorld.class文件放到%tomcat%\webapps\axis2\WEB-INF\pojo目录中(如果没有pojo目录,则建立该目录),然后打开浏览器进行测试:
输入一下url:
http://localhost:8080/axis2/services/listServices
会列出所有webservice
这是其中的两个webservice列表,接着,在客户端进行测试:
首先可以写一个封装类,减少编码,代码如下:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockStart.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
13
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
14
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
15
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
16
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
17
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
18
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
19
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
20
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
21
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
22
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
23
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
24
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
25
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
26
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
27
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
28
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
29
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
30
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
31
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
32
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
33
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
34
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
35
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
36
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
37
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
38
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
39
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
40
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
41
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
42
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
43
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
44
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
45
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
46
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
47
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
48
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
49
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
50
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
51
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
52
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
53
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
54
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
55
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
56
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
57
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
58
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
59
![](http://www.blogjava.net/Images/OutliningIndicators/InBlock.gif)
60
![](http://www.blogjava.net/Images/OutliningIndicators/ExpandedBlockEnd.gif)
61
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
客户端调用方法:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2.使用service.xml发布webservice,这种方式和直接放在pojo目录中的POJO类不同。要想将MyService类发布成Web Service,需要一个services.xml文件,这个文件需要放在META-INF目录中,该文件的内容如下:
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
其中<service>元素用于发布Web Service,一个<service>元素只能发布一个WebService类,name属性表示WebService名,如下面的URL可以获得这个WebService的WSDL内容:
http://localhost:8080/axis2/services/myService?wsdl
除此之外,还有直接可以在其中制定webservice操作方法:可以这样些service.xml文件
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
2
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
3
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
4
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
5
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
6
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
7
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
8
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
9
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
10
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
11
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
12
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
13
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
14
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
15
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
16
![](http://www.blogjava.net/Images/OutliningIndicators/None.gif)
如果要发布多个webservice,可以在文件两段加上<serviceGroup><service></service>...<service></service></serviceGroup>发布