風人園
弱水三千,只取一瓢,便能解渴;佛法無邊,奉行一法,便能得益。
隨筆 - 99, 文章 - 181, 評論 - 56, 引用 - 0
數據加載中……
在Spring集成XFire
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-03 16:42
風人園
閱讀(521)
評論(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參數(6275)
2.?JSF--整合spring(6096)
3.?hibernate 關聯查詢錯誤(Path expected for join)(4918)
4.?Ext應用三 -- Tab(2)(4860)
5.?hibernate 延遲加載的錯誤 failed to lazily initialize a collection of role(4812)
評論排行榜
1.?springmodule整合spring jbpm配置(16)
2.?Ext應用三 -- Tab(2)(5)
3.?JSF--整合spring(3)
4.?Rome使用入門(3)
5.?jBPM之swimlane (2)
主站蜘蛛池模板:
日韩在线永久免费播放
|
WWW国产成人免费观看视频
|
人妻无码一区二区三区免费
|
日本免费人成视频在线观看
|
亚洲午夜日韩高清一区
|
美女视频黄a视频全免费网站色
|
免费人成视网站在线观看不卡
|
中文字幕乱码亚洲无线三区
|
亚洲一区二区视频在线观看
|
朝桐光亚洲专区在线中文字幕
|
亚欧乱色国产精品免费视频
|
亚洲第一区精品日韩在线播放
|
国产精品亚洲AV三区
|
免费中文字幕一级毛片
|
a毛片成人免费全部播放
|
国产黄色一级毛片亚洲黄片大全
|
国产免费A∨在线播放
|
亚洲日韩aⅴ在线视频
|
久久久国产精品福利免费
|
老汉色老汉首页a亚洲
|
精品香蕉在线观看免费
|
亚洲日本va一区二区三区
|
国产免费观看视频
|
国产免费区在线观看十分钟
|
亚洲第一中文字幕
|
99爱在线精品免费观看
|
亚洲精品一卡2卡3卡四卡乱码
|
日韩免费一级毛片
|
在线免费视频你懂的
|
亚洲精品天天影视综合网
|
一个人免费高清在线观看
|
欧美激情综合亚洲一二区
|
亚洲国产精品一区二区第四页
|
免费人成激情视频在线观看冫
|
久久亚洲精精品中文字幕
|
成人免费午夜在线观看
|
国产av无码专区亚洲av毛片搜
|
亚洲第一区精品观看
|
久久国产乱子伦精品免费一
|
美女视频免费看一区二区
|
国产精品久久久亚洲
|