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
- 使用CXF與Spring整合實現RESTFul WebServiceSpringRESTWeb
- Spring整合CXF,釋出RSETful 風格WebServiceSpringWeb
- java框架整合Springmvc+mybatis+shiro+lucene+rest+webservice+mavenJava框架SpringMVCMyBatisRESTWebMaven
- webservice介面Web
- WebService基本Web
- soa == webServiceWeb
- 求助webserviceWeb
- WebService求助Web
- webservice testWeb
- Restful是什麼,SOAP Webservice和RESTful WebserviceRESTWeb
- webservice介面呼叫Web
- WebService XML SoapFormatterWebXMLORM
- WebService程式碼Web
- Webservice On NettyWebNetty
- WebService實戰Web
- 除錯WebService除錯Web
- 什麼是webserviceWeb
- Ajax呼叫WebService(一)Web
- C#呼叫webserviceC#Web
- webservice中呼叫structWebStruct
- webservice得到自身IPWeb
- WebService效能問題Web
- WebService 之 Restful ToolWebREST
- js 呼叫 WebService 方法JSWeb
- SpringBoot+webserviceSpring BootWeb
- C#釋出WebServiceC#Web
- java動態呼叫webserviceJavaWeb
- 新增webservice呼叫日誌Web
- Axis2呼叫WebServiceWeb
- WebService學習筆記Web筆記
- webservice傳輸檔案Web
- PHP呼叫Webservice例項PHPWeb
- OFBIZ webservice簡介Web
- 常用WebService一覽表Web
- android處理webserviceAndroidWeb
- SOAP和WebService真是垃圾。Web