项目中需要新增一个子应用,用于webservice请求,由于公司开发环境和运行环境等原因,上线后必须使用websphere5.1,这样就限制了运行环境,JDK1.4 servlet2.3,经过了一天的选型,最后确定了和以上环境兼容的开源框架,希望能帮助和我遇到一样情况的朋友们。
公布结果:axis2 1.2;spring-framework 2.5.6;ibatis 2.3.0
这应该是这三个框架最后一个支持JDK1.4的版本了,现已在websphere5.1上运行正常。
?
在集成框架之前,先说一下websphere有个地方需要修改,进入到websphere下bin目录,将qname.jar删除,需要添加一个高版本的qname.jar程序,我用的是wsdl4j-qname-1.6.1.jar,否则运行axis2的时候会出现一个类型文件版本不正确的异常信息。
?
现在开始集成,这里将不说明axis2的部署,可以参考axis2.war进行配置,并不会对spring和ibatis有影响。以下的配置介绍是包括axis2的,但不会具体说明。
?
1、web.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>CrmWebservice</display-name> <!-- 指定spring配置文件 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:spring/*.xml</param-value> </context-param> <!-- 指定log4j配置文件 --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </context-param> <!-- 指定spring监听器,由于servlet版本,不可使用spring的Listen配置方式 --> <servlet> <servlet-name>contextLoaderServlet</servlet-name> <servlet-class>org.springframework.web.context.ContextLoaderListener</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>AxisServlet</servlet-name> <display-name>Apache-Axis Servlet</display-name> <servlet-class>org.apache.axis2.transport.http.AxisServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet> <servlet-name>AxisAdminServlet</servlet-name> <display-name>Apache-Axis AxisAdmin Servlet (Web Admin)</display-name> <servlet-class>org.apache.axis2.transport.http.AxisAdminServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/servlet/AxisServlet</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>*.jws</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>AxisAdminServlet</servlet-name> <url-pattern>/axis2-admin/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>/axis2-web/index.jsp</welcome-file> </welcome-file-list> <error-page> <error-code>404</error-code> <location>/axis2-web/Error/error404.jsp</location> </error-page> <error-page> <error-code>500</error-code> <location>/axis2-web/Error/error500.jsp</location> </error-page> </web-app>
?2、applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd"> <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc:oracle:thin:@192.168.21.248:1521:recycle</value> </property> <property name="username"> <value>crm</value> </property> <property name="password"> <value>crm</value> </property> </bean> <!--spring整合ibatis --> <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="configLocation"><value>classpath:ibatis/SqlMapConfig.xml</value></property> <property name="dataSource" ref="dataSource" /> </bean> <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient" ref="sqlMapClient" /> </bean> <!-- 配置事务拦截器 --> <bean id="transactionIterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="transactionManager"></property> <property name="transactionAttributes"> <props> <prop key="insert*">PROPAGATION_REQUIRED</prop> <prop key="find*,get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <!--事务 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans>
?3、SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd"> <sqlMapConfig> <!-- 关联具体的ibatis配置文件 --> <sqlMap resource="ibatis/CrmOdexPlatAcco.xml" /> </sqlMapConfig>
?4、我的目录结构
?
基本配置完成,至少作为helloworld完成,这个时候就可以使用spring和ibatis了,还需要结构化的修改和重构,未来将不再更新,更多功能请参考spring和ibatis;
上传了我发布的源文件,由于lib目录过大,为了方便上载我就给删了,可以从开源需要的开源框架中获得!