Tibco GI+CXF2.3.1+Spring3.0整合示例

1.导入Spring和CXF的所有依赖包

2.在web.xml中配置Spring和CXF

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext-*.xml</param-value>
</context-param>

<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>



3.在applicationContext-common.xml中导入CXF的配置文件

<import resource="classpath:services.xml" />


4.编写webService的demo程序
4.1 biz接口


@WebService
public interface IUserBiz {

public User getFirstUser();
}

4.2 biz实现


@WebService(endpointInterface="com.founder.core.biz.IUserBiz")
public class UserBizImpl implements IUserBiz{

private IUserDao userDao;

public IUserDao getUserDao() {
return userDao;
}

public void setUserDao(IUserDao userDao) {
this.userDao = userDao;
}

public User getFirstUser() {
return userDao.getFirstUser();
}

}

4.3 Dao接口


public interface IUserDao {

public User getFirstUser();

}

4.4 Dao实现


public class UserDaoImpl implements IUserDao{

public User getFirstUser() {
User user = new User();
user.setId(1L);
user.setUserName("****");
user.setPassword("123");
user.setGender(true);
user.setAge(24);
user.setEmail("****@sina.com");
return user;
}

}

4.5 在Spring的配置文件中配置Dao的Bean


<bean id="userDao" class="com.core.dao.Impl.UserDaoImpl" />

4.6 在CXF的配置文件中将biz类注册成webService服务,并整合Spring,配置依赖


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<jaxws:endpoint id="UserBiz" address="/UserBiz" >
<jaxws:implementor>
<bean class="com.core.biz.Impl.UserBizImpl">
<property name="userDao">
<ref bean="userDao"/>
</property>
</bean>
</jaxws:implementor>
</jaxws:endpoint>
</beans>

4.7 启动tomcat访问,CXF与spring整合,并发布服务成功
http://127.0.0.1:8000/Test_Cxf/services/UserBiz?wsdl
http://127.0.0.1:8000/Test_Cxf/services/UserBiz/getFirstUser

5.使用Tibco GI编写页面
5.1使用Tools->xml Mapping Utility配置WebService
5.2字段与from之间由Object->name 匹配
5.3使用Generate生成调用JS
5.4配置button触发事件
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值