天天看點

bbossgroups 3.1中webservice引擎使用方法

bbossgroups 3.1中webservice引擎使用方法可以參考bbossgroups教育訓練教程的25-28頁,下載下傳位址: http://dl.iteye.com/topics/download/5e8d0f07-53c2-34f1-a0d8-ee43369774ea 也可以參考CXF WEBSERVICE測試用例: http://dl.iteye.com/topics/download/910322f9-0cb7-312b-935a-732504c43f63 架構包請及時更新最新版本 bboss ant建構指南 bbossgroups項目資源下載下傳: http://yin-bp.iteye.com/admin/blogs/1080824

14.9.2 通過aop元件配置cxf元件工廠調用方式

利用aop架構中的工廠元件管理模式,可以非常友善的擷取cxf webservice服務的客服端調用接口,進而友善地實作webservice服務調用。

14.9.2.1 客服端配置檔案

<properties>
   <property name="WSServiceClient" factory-bean="WSServiceClientFactory" factory-method="create"/>  
       
     <property name="WSServiceClientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">  
         <property name="serviceClass" value="org.frameworkset.web.ws.WSService"/>  
         <property name="address" value="http://localhost:8080/bboss-mvc/cxfservices/mysfirstwsservicePort"/>           
    </property>
</properties>        

說明:

WSServiceClient-代表webservice服務客服端接口元件名稱,客服端調用程式通過該名稱擷取服務調用接口執行個體,該執行個體通過工廠模式(元件建立工廠

WSServiceClientFactory的create方法建立)擷取。

WSServiceClientFactory-元件建立工廠(非靜态),webservice客服端通過該工廠的create執行個體方法來建立服務調用接口執行個體。在該工廠的定義中可以看出,為了建立webservice服務調用接口,需要指定兩個屬性serviceClass和address,通過serviceClass屬性指定了webservice服務對應的接口,address指定了webservice服務位址。

14.9.2.2 調用方法

public class WSClient {
	ApplicationContext context ; 
	@Before
	public void init()
	{
		context = ApplicationContext.getApplicationContext("org/frameworkset/web/ws/wsclient.xml"); 
	}
	@Test
	public void test()
	{
		org.frameworkset.web.ws.WSService wsservice =  (WSService)context.getBeanObject("WSServiceClient");
		System.out.println(wsservice.sayHello("多多"));
	}

}      

14.10 3.1版本對webservice服務釋出管理做了部分調整

3.1版本對webservice服務釋出管理做了部分調整,使得開發人員可以非常友善地釋出自己的webservice服務,這裡隻做調整部分的說明,至于服務的定義、部署、調用可以參考《bbossgroups教育訓練ppt》中25頁-28頁,這裡就不做過多的說明。

14.10.1 服務釋出調整

改進webservice服務裝載功能,可以從mvc控制器配置檔案和所有的applicationcontext對應的配置檔案中配置和裝載webservice服務:

在Mvc架構控制器檔案中配置的ws服務會在webservice引擎啟動時自動裝載。

普通的applicationcontext容器對應的配置檔案中配置的ws服務不能自動加載,我們需要将這些配置檔案單獨裝配到

org/frameworkset/spi/ws/webserivce-modules.xml檔案中,以便webservice引擎啟動時通過掃描org/frameworkset/spi/ws/webserivce-modules.xml中裝配的元件配置檔案來裝載其中配置的webservice服務。

org/frameworkset/spi/ws/webserivce-modules.xml檔案時3.1版本中新加的用來裝配獨立applicationcontext中配置的ws服務的部署描述檔案。

3.1版本任然相容舊版的webservice服務釋出方法,即配置在

/bbossaop/resources/org/frameworkset/spi/manager-rpc-webservices.xml中的

cxf.webservices.config屬性中配置的服務任然會被加載和釋出。

14.10.2 org/frameworkset/spi/ws/webserivce-modules.xml裝載服務執行個體

<properties>
<!-- 
		webservice服務元件裝配檔案,每個檔案作為單獨的容器來處理,這裡裝配的是classpath上下文中需要獨立加載的webservice服務
		mvc架構中需要加載的webservice服務隻需要在對應的元件中标注servicePort即可,當webservice引擎啟動時會加載這兩種模式下的
		所有webservice服務		
		需要注意的是,webservice引擎需要在mvc架構啟動後在啟動
	 -->
	<property name="cxf.webservices.modules">
		<array componentType="String">
			<property value="org/frameworkset/spi/ws/protocol-ws.xml"/>
		</array>
	</property>
	<property name="cxf.webservices.loader.order" value="mvc,cxf.webservices.modules">		
	</property>
	
	<!-- 本元件依賴于bboss-mvc.jar -->
	<property name="webapplicationcontext" factory-class="org.frameworkset.web.servlet.support.WebApplicationContextUtils" factory-method="getWebApplicationContext"/>	
</properties>      

14.10.3 服務定義調整

Bbossgroups中通過在property元素上指定ws:servicePort 屬性來辨別webservice服務。3.1之前的服務定義是通過在property元素上設定servicePort屬性來辨別一個webservice服務的,例如:

<property name="rpc.webservice.RPCCall" 
					  singlable="true" 
					  servicePort="RPCCallServicePort"		
class="org.frameworkset.spi.remote.webservice.RPCCall"/>      

3.1版本中辨別webservice服務的屬性變更為ws: servicePort,服務釋出引擎通過識别帶ws:字首的屬性來識别webservice服務,并釋出該服務,例如:

<property name="rpc.webservice.RPCCall" 
					  singlable="true" 
					  ws:servicePort="RPCCallServicePort"	
class="org.frameworkset.spi.remote.webservice.RPCCall"/>      

繼續閱讀