一,开发WebService服务端
1. 新建Web Service Project




完成后如下图

2. 编写接口与实现类,修改xfire配置
接口IHello.java代码如下:
package com.lingyu.webservice.server;
/**
*
* @author lingyu
*/
public interface IHello {
String sayHello(String name);
}
HelloImpl.java
package com.lingyu.webservice.server;
/**
* @author lingyu
*/
public class HelloImpl implements IHello {
public String sayHello(String name) {
return "Hello,"+name;
}
}
修改servicices.xml,修改后内容如下
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<service xmlns="http://xfire.codehaus.org/config/1.0">
<name>Hello</name>
<namespace>http://www.openuri.org/</namespace>
<serviceClass>com.lingyu.webservice.server.IHello</serviceClass>
<implementationClass>
com.lingyu.webservice.server.HelloImpl
</implementationClass>
<style>wrapped</style>
<use>literal</use>
<scope>application</scope>
</service>
</beans>

3. 把HelloWebService部署到tomcat,
启动tomcat后,在IE打开:http://localhost:8080/HelloWebService/services/
部署成功会看到

点击[wsdl],可看到

至此,HelloWebService服务端开发完成。
本文详细介绍了使用XFire框架搭建WebService服务的过程,包括创建项目、编写接口与实现类、配置服务及部署到Tomcat等步骤。
173

被折叠的 条评论
为什么被折叠?



