日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
Spring集成XFire開發(fā)WebService

XFire是一個(gè)簡化WebService開發(fā)的開源項(xiàng)目,通過Spring集成XFire可以大大簡化基于Spring Framework的應(yīng)用中的WebService開發(fā)。

創(chuàng)新互聯(lián)成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站建設(shè)、做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢想脫穎而出為使命,1280元富縣做網(wǎng)站,已為上家服務(wù),為富縣各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792

Spring集成XFire可以通過多種方式結(jié)合,下文介紹的是筆者常用的一種簡單而實(shí)用的方法。所用的Spring版本為2.0,XFire版本為1.2.6。


Spring集成XFire之一:配置XFire Servlet


  在web.xml中加入如下配置:

<servlet>
<servlet-name>XFireServlet</servlet-name>
 <servlet-class>
  org.codehaus.xfire.spring.XFireSpringServlet
?。?servlet-class>
</servlet>
<servlet-mapping>
?。約ervlet-name>XFireServlet</servlet-name>
?。紆rl-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
 <servlet-name>XFireServlet</servlet-name>
?。紆rl-pattern>/services/*</url-pattern>
</servlet-mapping>


Spring集成XFire之二:配置Spring的監(jiān)聽器,同基于spring的Web項(xiàng)目一樣Spring的監(jiān)聽器是必不可少的。

<context-param>
 <param-name>contextConfigLocation</param-name>
?。紁aram-value>
  classpath:org/codehaus/xfire/spring/xfire.xml,
  /WEB-INF/applicationContext.xml
?。?param-value>
</context-param>
<listener>
 <listener-class>
  org.springframework.web.context.ContextLoaderListener
 </listener-class>
</listener>

以下是為開發(fā)WebService而編寫的完整的web.xml配置文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
 xmlns="http://java.sun.com/xml/ns/j2ee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
?。糲ontext-param>
  <param-name>contextConfigLocation</param-name>
 ?。紁aram-value>
   classpath:org/codehaus/xfire/spring/xfire.xml,
   /WEB-INF/applicationContext.xml
 ?。?param-value>
 </context-param>
<listener>
?。糽istener-class>
  org.springframework.web.context.ContextLoaderListener
?。?listener-class>
</listener>
<servlet>
 <servlet-name>XFireServlet</servlet-name>
?。約ervlet-class>
  org.codehaus.xfire.spring.XFireSpringServlet
 </servlet-class>
</servlet>
<servlet-mapping>
?。約ervlet-name>XFireServlet</servlet-name>
?。紆rl-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
?。約ervlet-name>XFireServlet</servlet-name>
 <url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>


Spring集成XFire之三:定義接口及實(shí)現(xiàn)服務(wù)

定義接口,這個(gè)接口中定義要通過WebService暴露的方法

package org.ccsoft;

publicinterface HelloWS {
 public String sayHello(String sb);
}

實(shí)現(xiàn)服務(wù)

package org.ccsoft;

publicclass HelloWSImp implements HelloWS {
 public String sayHello(String sb) {
  // TODO Auto-generated method stub
  return"Hello "+sb;
 }
}


Spring集成XFire之四:配置服務(wù)

將上文中實(shí)現(xiàn)的服務(wù),加入到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"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="helloWS" class="org.ccsoft.HelloWSImp"/>
<bean name="helloService" class="org.codehaus.xfire.spring.ServiceBean">
<property name="serviceBean" ref="helloWS"/>
<property name="serviceClass" value="org.ccsoft.HelloWS"/>
<property name="inHandlers">
?。糽ist>
 ?。紃ef bean="addressingHandler"/>
?。?list>
</property>
</bean>

<bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler"/>
</beans>

【編輯推薦】

  1. 高手Java核心技術(shù)學(xué)習(xí)筆記
  2. 告訴你怎樣學(xué)Java才是硬道理
  3. 如何獲取Sun推出的Java認(rèn)證
  4. 共同學(xué)習(xí)Java環(huán)境變量
  5. JAVA環(huán)境變量的設(shè)置

分享標(biāo)題:Spring集成XFire開發(fā)WebService
網(wǎng)站網(wǎng)址:http://www.5511xx.com/article/cdsccds.html