package com.test;
import java.util.ArrayList;
import java.util.List;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.ms.model.UserInfo;
import com.ms.services.IHelloServices;
public class Client {
public static void main(String[] args) {
invokeBySpring();
}
public static void invoke(){
//创建WebService客户端代理工厂
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
//注册WebService接口
factory.setServiceClass(IHelloServices.class);
//设置WebService地址
factory.setAddress("http://localhost:8090/CxfServer_Spring/services/HelloServices");
IHelloServices helloServices = (IHelloServices)factory.create();
System.out.println("invoke helloServices webservice...");
String hello = helloServices.sayHello("vicky");
List<UserInfo> users = new ArrayList<UserInfo>();
users.add(new UserInfo("vicky",23));
users.add(new UserInfo("caty",23));
users.add(new UserInfo("ivy",23));
users.add(new UserInfo("kelly",23));
String helloAll = helloServices.sayHelloToAll(users);
System.out.println(hello);
System.out.println(helloAll);
}
public static void invokeBySpring(){
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext-client.xml");
IHelloServices helloServices = context.getBean("helloClient",IHelloServices.class);
List<UserInfo> users = new ArrayList<UserInfo>();
users.add(new UserInfo("vicky",23));
users.add(new UserInfo("caty",23));
users.add(new UserInfo("ivy",23));
users.add(new UserInfo("kelly",23));
String helloAll = helloServices.sayHelloToAll(users);
System.out.println(helloAll);
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
CXF结合Spring开发WebServices示例工程
共29个文件
class:6个
xml:6个
java:6个
5星 · 超过95%的资源 需积分: 9 38 下载量 116 浏览量
2011-07-14
18:21:14
上传
评论
收藏 26KB ZIP 举报
温馨提示
使用CXF结合Spring开发WebServices示例工程,包括服务端与客户端的详细代码。
资源推荐
资源详情
资源评论
收起资源包目录
cxf_spring_demo.zip (29个子文件)
cxf_spring_demo
CxfClient_Spring
WebContent
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 381B
classes
com
test
Client.class 2KB
ms
model
UserInfo.class 949B
services
IHelloServices.class 397B
applicationContext-client.xml 920B
lib
index.jsp 806B
src
com
test
Client.java 2KB
ms
model
UserInfo.java 521B
services
IHelloServices.java 262B
applicationContext-client.xml 920B
.project 1018B
.mymetadata 324B
.classpath 3KB
.myeclipse
CxfServer_Spring
WebContent
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 1KB
classes
applicationContext-server.xml 1KB
com
ms
model
UserInfo.class 949B
services
IHelloServices.class 397B
impl
HelloServicesImpl.class 2KB
lib
index.jsp 806B
.settings
org.eclipse.jdt.core.prefs 330B
src
applicationContext-server.xml 1KB
com
ms
model
UserInfo.java 521B
services
IHelloServices.java 262B
impl
HelloServicesImpl.java 575B
.project 1KB
.mymetadata 324B
.classpath 3KB
.myeclipse
共 29 条
- 1
iam-Vicky
- 粉丝: 106
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页