XFire的简单使用

XFire是新一代的Java Web服务引擎,XFire使得在JavaEE应用中发布Web服务变得轻而易举。和其他Web服务引擎相比,XFire的配置非常简单,可以非常容易地和其他众多系统集成!这个是以前自己学XFire的时候写的小Demo!
好!进入主题,首先加载Servlet处理Services请求:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.transport.http.XFireConfigurableServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>

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

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

配置WebServices服务:
<?xml version="1.0" encoding="UTF-8"?>
<beans>
<service xmlns="http://xfire.codehaus.org/config/1.0"
xmlns:s="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<name>softceo</name>
<namespace>www.softceo.com</namespace>
<serviceClass>soft.ceo.whilr.bean.IProcess</serviceClass>
<implementationClass>
soft.ceo.whilr.bean.Process
</implementationClass>
</service>
</beans>

接下来时接口的实现方法:
package soft.ceo.whilr.bean;

public class Process implements IProcess {

public String outString() {
return "你调用了小旋风的远程方法!";
}

}


最后就是Client的调用了:
package com.test.other;

import java.net.MalformedURLException;

import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
//import org.apache.commons.httpclient/Credentials;
import soft.ceo.whilr.bean.IProcess;

/**
*
* @author softceo945
*
*/
public class Test {

/**
* @param args
*/
public static void main(String[] args) {
// TODO 自动生成方法存根

Service srvcModel = new ObjectServiceFactory().create(IProcess.class);
XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());

String helloWorldURL = "http://localhost:8088/TestServices/services/softceo";

IProcess process=null;
try {
process = (IProcess) factory.create(srvcModel, helloWorldURL);
} catch (MalformedURLException e) {
e.printStackTrace();
}
System.out.println(process.outString());



}

}

由于是以前写的代码,有很多不规范的地方!见谅!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值