Tibco GI+CXF 2.11+Spring 3.0統合例
4261 ワード
1.SpringとCXFのすべての依存パッケージを導入する
2.web.xmlにSpringとCXFを配置する
4.1 BIzインターフェース
http://127.0.0.1:8000/Test_Cxf/services/UserBiz?wdl
http://127.0.0.1:8000/Test_Cxf/services/UserBiz/get First User
5.Tibco GIを使ってページを作成する
5.1 Tools->xml Mapping UtilityでWebServiceを設定する
5.2フィールドとfromの間はObject->nameで一致します.
5.3 Generateを使ってJSを呼び出します.
5.4設定buttonトリガイベント
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.appication-common.xmlにCXFのプロファイルを導入する
<import resource="classpath:services.xml" />
4.webServiceのデモプログラムを作成する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?wdl
http://127.0.0.1:8000/Test_Cxf/services/UserBiz/get First User
5.Tibco GIを使ってページを作成する
5.1 Tools->xml Mapping UtilityでWebServiceを設定する
5.2フィールドとfromの間はObject->nameで一致します.
5.3 Generateを使ってJSを呼び出します.
5.4設定buttonトリガイベント