xfire+spring整合webservice
伺服器端:
1、建立一個新的專案springXfireWebService (客戶端)
2、在官網http://xfire.codehaus.org/Download中下載:xfire-distribution-1.2.6.zip (在建立專案後將所有jar包放到lib包中,測試刪掉幾個發現不行,似乎都是需要的,忘高手指明不足)和xfire-all-1.2.6.jar 。
3、建立webService:
4、實現:
5、引入jar包:xfire-distribution-1.2.6.zip 裡面的包、xfire-all-1.2.6.jar和spring-2.5.6.jar。
6、與spring整合spring-context.xml:
7、配置web.xml:
8、啟動專案springXfireWebService (客戶端),沒有出錯 第一步OK啦!!
客戶端:
1、建立新的專案springXfireClient(客戶端)
2、建立service:
3、建立test.java
4、在控制檯出現:
Hello
完成。注意這裡沒有涉及到與資料庫的互動,可以在實現中完善,另外在在spirng中配置。
1、建立一個新的專案springXfireWebService (客戶端)
2、在官網http://xfire.codehaus.org/Download中下載:xfire-distribution-1.2.6.zip (在建立專案後將所有jar包放到lib包中,測試刪掉幾個發現不行,似乎都是需要的,忘高手指明不足)和xfire-all-1.2.6.jar 。
3、建立webService:
- package com.ebiz.xfire.service;
- import java.util.List;
- import com.ebiz.xfire.domain.CscProject;
- /**
- * @author Ethan,Woo
- */
- public interface CscWebService {
- /**
- *@author Ethan,Woo
- *@desc "載入專案庫資料"
- *@date 2009-09-28
- */
- List<CscProject> getCscProjectList(CscProject t);
- }
4、實現:
- package com.ebiz.xfire.service.impl;
- import com.ebiz.xfire.service.WyWebService;
- /**
- * @author Ethan,Woo
- */
- public class WyWebServiceImpl implements WyWebService {
- public void printHello() {
- System.out.println("Hello!");
- }
- }
5、引入jar包:xfire-distribution-1.2.6.zip 裡面的包、xfire-all-1.2.6.jar和spring-2.5.6.jar。
6、與spring整合spring-context.xml:
- <?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
- xmlns:jee="http://www.springframework.org/schema/jee" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
- http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
- http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
- default-autowire="byName">
- <import resource="classpath:org/codehaus/xfire/spring/xfire.xml" />
- <!-- ====================testSpringXfire================= -->
- <bean id="wyWebServiceImpl" class="com.ebiz.xfire.service.impl.WyWebServiceImpl" />
- <bean id="addressingHandler" class="org.codehaus.xfire.addressing.AddressingInHandler" />
- <bean name="webService" class="org.codehaus.xfire.spring.ServiceBean">
- <property name="serviceBean" ref="wyWebServiceImpl"></property>
- <property name="serviceClass" value="com.ebiz.xfire.service.WyWebService"></property>
- <property name="inHandlers">
- <list>
- <ref bean="addressingHandler" />
- </list>
- </property>
- </bean>
- </beans>
7、配置web.xml:
- <?xml version="1.0" encoding="UTF-8"?>
- <web-app id="WebApp_ID" 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">
- <display-name>XFireTest</display-name>
- <welcome-file-list>
- <welcome-file>index.html</welcome-file>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>classpath:spring-context.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <servlet>
- <servlet-name>XFireServlet</servlet-name>
- <servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
- </servlet>
- <servlet-mapping>
- <servlet-name>XFireServlet</servlet-name>
- <url-pattern>/servlet/XFireServlet/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>XFireServlet</servlet-name>
- <url-pattern>/services/*</url-pattern>
- </servlet-mapping>
- </web-app>
8、啟動專案springXfireWebService (客戶端),沒有出錯 第一步OK啦!!
客戶端:
1、建立新的專案springXfireClient(客戶端)
2、建立service:
- package com.ebiz.xfire.service;
- /**
- * @author Ethan,woo
- * @version 2009-09-28
- */
- public interface WyWebService {
- /**
- *@desc "列印Hello"
- */
- void printHello();
- }
- 注意:這裡的包的目錄結構一定要和客戶端的包的結構一定要一樣(本人吃過虧的~~~~(>_<)~~~~ )
3、建立test.java
- package com.testxfire.client;
- import java.net.MalformedURLException;
- import org.codehaus.xfire.XFireFactory;
- import org.codehaus.xfire.client.XFireProxyFactory;
- import org.codehaus.xfire.service.Service;
- import org.codehaus.xfire.service.binding.ObjectServiceFactory;
- import com.ebiz.xfire.service.WyWebService;
- public class Test {
- public static void main(String[] args) {
- Service serviceModel = new ObjectServiceFactory().create(WyWebService.class);
- XFireProxyFactory factory = new XFireProxyFactory(XFireFactory.newInstance().getXFire());
- String url = "http://localhost:8080/springXfireWebService/services/WyWebService";
- try {
- WyWebService cws = (WyWebService) factory.create(serviceModel, url);
- cws.printHello();
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- }
- }
4、在控制檯出現:
Hello
完成。注意這裡沒有涉及到與資料庫的互動,可以在實現中完善,另外在在spirng中配置。
相關文章
- springboot2.0整合webserviceSpring BootWeb
- WebService之Spring+CXF整合示例WebSpring
- java框架整合Springmvc+mybatis+shiro+lucene+rest+webservice+mavenJava框架SpringMVCMyBatisRESTWebMaven
- webservice介面呼叫Web
- SpringBoot+webserviceSpring BootWeb
- 細說WebServiceWeb
- webservice簡介Web
- WebService XML SoapFormatterWebXMLORM
- 什麼是webserviceWeb
- C#釋出WebServiceC#Web
- webapi建立和呼叫WebServiceWebAPI
- web api 、webservice 跨域等WebAPI跨域
- WebService就是這麼簡單Web
- WebService的概念和基本使用Web
- WebService共享資料的使用Web
- python 搭建 webservice 服務端PythonWeb服務端
- webservice和jms的區別Web
- webservice修改名稱空間Web
- 一種WebService的呼叫方式Web
- 十九、.net core使用SoapCore開發webservice介面,以及使用HttpClientFactory動態訪問webservice介面WebHTTPclient
- 騰訊WebService Api 跨域呼叫WebAPI跨域
- 一些常用的WebService.Web
- VS2010 建立 新增 Webservice 程式Web
- webservice快速入門-SOAP和WSDL(三)Web
- java webService 零基礎學習JavaWeb
- SpringBoot與WebService的簡單實現Spring BootWeb
- RestCloud ETL WebService資料同步到本地RESTCloudWeb
- WebService安全機制的思考與實踐Web
- java webservice 帶請求頭方式處理JavaWeb
- springmvc+mybatis+restful+webservice Jeesz分散式架構SpringMVCMyBatisRESTWeb分散式架構
- 關於Webservice介面對接相關總結Web
- 用WebService呼叫第三方天氣介面Web
- BIRT 怎麼呼叫 Webservice 作為資料來源Web
- 好程式設計師分享WebService的簡單使用程式設計師Web
- 基於 Spring Boot 2.0 構建一個 RESTful WebServiceSpring BootRESTWeb
- 使用RestCloud ETL輕鬆解決WebService資料同步RESTCloudWeb
- 實踐基於REST風格的Webservice(PHP,C#)RESTWebPHPC#
- 叢集、分散式、SOA、微服務、webService等思想的整理分散式微服務Web
- Android技能樹 — 網路小結(4)之socket/websocket/webserviceAndroidWeb