XFire小记

最近一个项目中需要用到Webservice向客户端提供各种服务。最初在选Webservice实现上考虑过AXIS1、XFire和CXF。尽管AXIS1技术成熟文档全面,但考虑其部署繁琐维护成本较高最终放弃。在看到XFire官方的一段说明后,初步决定使用CXF。

 

XFire官方说明

User's looking to use XFire on a new project, should use CXF instead. CXF is a continuation of the XFire project and is considered XFire 2.0. It has many new features, a ton of bug fixes, and is now JAX-WS compliant! XFire will continue to be maintained through bug fix releases, but most development will occur on CXF now. For more information see the XFire/Celtix merge FAQ and the CXF website .

 

后来由于客户提供的软件运行环境为Websphere6.0,而CXF需要JDK 5.0支持而不得不放弃,最后选择了XFire。总得来说XFire支持的特性广泛、配置部署简单,另外与Spring结合也相当方便,XFire也算是个不错的选择。

 

XFire之Hello World

1 创建一个Web工程,导入XFire所需jar包



2 配置web.xml

 

<!-- XFIRE配置 -->
<servlet>
	<servlet-name>XFireServlet</servlet-name>
	<display-name>XFire Servlet</display-name>
	<servlet-class>
		org.codehaus.xfire.transport.http.XFireConfigurableServlet
	</servlet-class>
</servlet>

<servlet-mapping>
	<servlet-name>XFireServlet</servlet-name>
	<url-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
	<servlet-name>XFireServlet</servlet-name>
	<url-pattern>/services/*</url-pattern>
</servlet-mapping>

 

3 在src下创建META-INF子目录,再在META-INF目录下创建xfire子目录,最后在xfire目录下创建services.xml文件

4 编写服务类接口HiService和实现类HiServiceImpl

package com.ws;

public interface HiService {
	public void sayHi();
}

 

package com.ws;

public class HiServiceImpl implements HiService {
	public void sayHi(){
		System.out.println("Hello world");
	}
}

 

5 配置service.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xfire.codehaus.org/config/1.0">
	<service>
		<name>HiService</name>
		<namespace>
			http://com.ws/HiService
		</namespace>
		<serviceClass>
			com.ws.HiService
		</serviceClass>
		<implementationClass>
			com.ws.HiServiceImpl
		</implementationClass>
	</service>
</beans>

 

6 发布查看服务

以Web工程形式发布即可。

查看服务http://localhost:8080/Hi/services

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值