風人園
弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
數據加載中……
spring 中集成 xfire(ZT)
XFire可以很好的集成到Spring中,Spring的代碼已經做了這方面的集成。
首先,我們先創建我們的Web服務,采用接口和實現類的方式:
接口MathService.java:
package?com.kuaff.xfire.samples;
public?interface?MathService
{
????public?long?add(int?p1,?int?p2);
}
實現類:
package?com.kuaff.xfire.samples;
public?class?MathServiceImpl?implements?MathService
{
????public?long?add(int?p1,?int?p2)
????{
????????return?p1?+?p2;
????}
}
META-INF/xfire/service.xml文件可以省略了,因為web服務的定義在xfire-servlet.xml中可以找到。
下面要做的工具就是配置了。
在WEB-INF文件夾下創建applicationContext.xml文件,這是Spring的配置文件,如果你使用其他的Spring配置文件,可以將下面的bean添加到那個配置文件中:
<?xml?version="1.0"?encoding="UTF-8"?>
<!DOCTYPE?beans?PUBLIC?"-//SPRING//DTD?BEAN//EN"?"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
????<bean?id="mathBean"?class="com.kuaff.xfire.samples.MathServiceImpl"/>
</beans>
定義了mathBean,這個Bean就是我們的實現類,當然你也可以在這個文件中定義其他的需要Spring管理的bean。
在WEB-INF文件夾下創建xfire-servlet.xml文件,根據Spring規范,這個文件名起做xfire-servlet.xml,其中xfire是web.xml配置的DispatcherServlet的名稱:
<?xml?version="1.0"?encoding="UTF-8"?>
<!DOCTYPE?beans?PUBLIC?"-//SPRING//DTD?BEAN//EN"?"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
????<bean?class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
????????<property?name="urlMap">
????????????<map>
????????????????<entry?key="/MathService">
????????????????????<ref?bean="math"/>
????????????????</entry>
????????????</map>
????????</property>
????</bean>
???
????<bean?id="math"?class="org.codehaus.xfire.spring.remoting.XFireExporter">
????????<property?name="serviceFactory">
????????????<ref?bean="xfire.serviceFactory"/>
????????</property>
????????<property?name="xfire">
????????????<ref?bean="xfire"/>
????????</property>
????????<property?name="serviceBean">
????????????<ref?bean="mathBean"/>
????????</property>
????????<property?name="serviceClass">
????????????<value>com.kuaff.xfire.samples.MathService</value>
????????</property>
????</bean>
</beans>
這個文件的上半部分將MathService這個URL和math這個bean聯系在一起。下半部分定義了Web服務的bean和服務接口。其中mathBean是我們在applicationContext.xml中配置的那個Bean。
最后一步就是修改web.xml文件:
<?xml?version="1.0"?encoding="ISO-8859-1"?>
<!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>
????<context-param>
????????<param-name>contextConfigLocation</param-name>
????????<param-value>/WEB-INF/applicationContext.xml
????????classpath:org/codehaus/xfire/spring/xfire.xml</param-value>
????</context-param>
????<context-param>
????????<param-name>log4jConfigLocation</param-name>
????????<param-value>/WEB-INF/log4j.properties</param-value>
????</context-param>
????<listener>
????????<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
????</listener>
????<listener>
????????<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
????</listener>
????<servlet>
????????<servlet-name>xfire</servlet-name>
????????<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
????</servlet>
????<servlet-mapping>
????????<servlet-name>xfire</servlet-name>
????????<url-pattern>/*</url-pattern>
????</servlet-mapping>
</web-app>
需要注意這個文件的三個部分:
?
1.??????在定義contextConfigLocation參數時一定要加上classpath:org/codehaus/xfire/spring/xfire.xml。
2.??????定義listener:?org.springframework.web.context.ContextLoaderListener
3.??????定義DispatcherServlet:?xfire
這樣,你就可以訪問http://localhost:8080/xfire/MathService來調用這個Web服務,也可以通過網址http://localhost:8080/xfire/MathService?wsdl來查看wsdl文檔。
posted on 2006-07-28 11:28
風人園
閱讀(220)
評論(0)
編輯
收藏
所屬分類:
Spring
Powered by:
BlogJava
Copyright © 風人園
導航
BlogJava
首頁
新隨筆
聯系
聚合
管理
<
2025年5月
>
日
一
二
三
四
五
六
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(11)
給我留言
查看公開留言
查看私人留言
隨筆分類
.Net(2)
(rss)
Android(9)
(rss)
Common(1)
(rss)
Eclipse/myEclipse(2)
(rss)
ECP(11)
(rss)
Ext(9)
(rss)
Hibernate(6)
(rss)
iBatis(3)
(rss)
J2EE
(rss)
Java(9)
(rss)
jBPM(10)
(rss)
jQuery(1)
(rss)
JSF(5)
(rss)
MQ(1)
(rss)
OperaMasks(4)
(rss)
PHP(2)
(rss)
Profiler(1)
(rss)
ROR(4)
(rss)
Ruby(2)
(rss)
Spring(6)
(rss)
SpringSecurity(3)
(rss)
Struts2(6)
(rss)
隨筆檔案
2018年3月 (3)
2017年5月 (1)
2016年12月 (5)
2016年11月 (4)
2014年3月 (1)
2013年6月 (1)
2012年4月 (2)
2012年2月 (1)
2011年11月 (1)
2011年9月 (2)
2011年8月 (1)
2010年12月 (2)
2009年12月 (1)
2009年11月 (2)
2009年9月 (3)
2009年8月 (19)
2009年6月 (4)
2009年4月 (1)
2008年10月 (1)
2008年7月 (1)
2008年3月 (5)
2008年2月 (1)
2008年1月 (6)
2007年12月 (3)
2007年7月 (2)
2007年6月 (1)
2007年5月 (11)
2007年4月 (5)
2007年1月 (6)
2006年12月 (1)
2006年7月 (1)
文章分類
AJAX(3)
(rss)
AP Server(1)
(rss)
Cache(3)
(rss)
CSS(1)
(rss)
DAO(4)
(rss)
Database(12)
(rss)
Design Pattern
(rss)
DotNet(10)
(rss)
Eclipse(7)
(rss)
Enterprise(1)
(rss)
iOS(1)
(rss)
J2EE(1)
(rss)
Java(47)
(rss)
JavaScript(10)
(rss)
JBoss(2)
(rss)
Linux(3)
(rss)
Open Source(5)
(rss)
Oracle(4)
(rss)
Other(1)
(rss)
PHP(1)
(rss)
Spring(13)
(rss)
Struts(11)
(rss)
SWT(1)
(rss)
Test(3)
(rss)
Web(27)
(rss)
Web Service(3)
(rss)
XML(1)
(rss)
感悟(1)
(rss)
生活(7)
(rss)
算法(2)
(rss)
文章檔案
2018年3月 (1)
2014年3月 (1)
2012年7月 (1)
2011年11月 (1)
2010年7月 (1)
2010年6月 (1)
2009年9月 (1)
2009年8月 (1)
2009年6月 (1)
2009年5月 (1)
2009年4月 (4)
2008年10月 (1)
2008年7月 (1)
2008年4月 (1)
2008年3月 (1)
2008年2月 (2)
2008年1月 (2)
2007年12月 (4)
2007年11月 (3)
2007年10月 (3)
2007年9月 (8)
2007年8月 (1)
2007年7月 (2)
2007年6月 (1)
2007年5月 (8)
2007年4月 (2)
2007年3月 (14)
2007年2月 (5)
2007年1月 (12)
2006年12月 (24)
2006年11月 (1)
2006年9月 (1)
2006年8月 (1)
2006年7月 (35)
2006年6月 (31)
2006年4月 (1)
新聞檔案
2015年10月 (1)
收藏夾
生活
(rss)
友情鏈接
中文愛百科
搜索
最新評論
1.?re: JSF--ajax4jsf入門示例(repeater)[未登錄]
dafdfa
--dd
2.?re: eclipse網絡連接代理設置
very good
--matz
3.?re: SOP入門---第一個Spring AOP程式 [未登錄]
非常感謝,我找的就是這個
--brave
4.?re: Spring MVC異常處理(ZT)
寫得可以哦。
--紅淚
5.?re: Spring MVC異常處理(ZT)
評論內容較長,點擊標題查看
--類
閱讀排行榜
1.?eclipse中啟動tomcat的時配置jvm參數(6271)
2.?JSF--整合spring(6093)
3.?hibernate 關聯查詢錯誤(Path expected for join)(4917)
4.?Ext應用三 -- Tab(2)(4858)
5.?hibernate 延遲加載的錯誤 failed to lazily initialize a collection of role(4808)
評論排行榜
1.?springmodule整合spring jbpm配置(16)
2.?Ext應用三 -- Tab(2)(5)
3.?JSF--整合spring(3)
4.?Rome使用入門(3)
5.?jBPM之swimlane (2)
主站蜘蛛池模板:
精品亚洲一区二区三区在线观看
|
毛片网站免费在线观看
|
亚洲日韩VA无码中文字幕
|
色婷婷亚洲一区二区三区
|
国产精品无码一二区免费
|
亚洲AV无码AV日韩AV网站
|
国产三级免费观看
|
亚洲AV成人精品日韩一区
|
在线亚洲高清揄拍自拍一品区
|
最近中文字幕完整免费视频ww
|
亚洲美女免费视频
|
在线观看免费人成视频色9
|
99999久久久久久亚洲
|
免费无码成人AV片在线在线播放
|
亚洲精品中文字幕
|
亚洲午夜精品第一区二区8050
|
国产在线观a免费观看
|
亚洲美女精品视频
|
精品国产精品久久一区免费式
|
国产亚洲精品免费
|
亚洲国产一二三精品无码
|
91精品国产免费久久国语蜜臀
|
国产成A人亚洲精V品无码性色
|
暖暖免费在线中文日本
|
亚洲色大成网站www永久
|
搡女人免费视频大全
|
免费看又黄又爽又猛的视频软件
|
亚洲人成网77777亚洲色
|
97在线视频免费
|
亚洲国产精品无码第一区二区三区
|
免费一级黄色毛片
|
久久午夜夜伦鲁鲁片无码免费
|
99久久婷婷国产综合亚洲
|
亚洲视频在线免费
|
1000部国产成人免费视频
|
国产青草亚洲香蕉精品久久
|
国产成人无码综合亚洲日韩
|
女人被男人躁的女爽免费视频
|
国产A∨免费精品视频
|
亚洲最大黄色网站
|
免费在线观看视频a
|