我必須編寫一個可以遠程訪問的服務。 我正在使用cxf-dosgi-ri-singlebundle-distribution-1.4.0。 所以我做了API,然後實施,這些特性:分佈式OSGi - 使用服務
Dictionary<String, String> restProps = new Hashtable<String, String>();
restProps.put("service.exported.interfaces", "*");
restProps.put("service.exported.configs", "org.apache.cxf.ws");
restProps.put("org.apache.cxf.ws.address", "http://192.168.0.3:9090/preview");
bundleContext.registerService(Preview.class.getName(), new PreviewService(),restProps);
如果我部署包,我可以看到在瀏覽器中的WSDL(部署API和d-OSGi的罐子後),甚至從遠程計算機。 「http://192.168.0.3:9090/preview?wsdl」這樣的。
但後來消費者。還有就是OSGI-INF /遠程服務/遠程的services.xml在客戶端罐子:
<endpoint-descriptions xmlns="http://www.osgi.org/xmlns/rsa/v1.0.0">
<endpoint-description>
<property name="objectClass">
<array>
<value>com.liferay.preview.api</value>
</array>
</property>
<property name="endpoint.id">http://192.168.0.3:9090/preview</property>
<property name="service.imported.configs">org.apache.cxf.ws</property>
</endpoint-description>
</endpoint-descriptions>
我可以部署束(部署d-OSGi包和API之後),但我總是回來空引用。 該教程始終使用代碼這樣
st = new ServiceTracker(bundleContext, MyService.class.getName(), null) {
@Override
public Object addingService(ServiceReference reference) {
Object svc = bundleContext.getService(reference);
if (svc instanceof MyService) {
printServiceInfo((MyService) svc);
}
return super.addingService(reference);
}
};
st.open();
但我使用的Liferay 7,在這裏我不能用這個(沒有構造函數ServiceTracker的 - 我只能得到一個ServiceTracker的實例從Registry實例回)
OSGi容器是Felix。
我在什麼地方讀它,如果我能訪問的WSDL描述,從上面可以看出, 和我們說,有你好()在我的API,然後 「http://192.168.0.3:9090/preview/hello」呼應該工作的方法..但它沒有。 我甚至不知道,如何調試。 (沒有遠程的東西,在本地,在同一個容器中,方法調用正在工作)
任何幫助都可能會好起來!謝謝!
那麼在這種情況下,客戶端將不需要任何remote-services.xml? –
正是。有關更多詳細信息,請參閱本教程http://liquid-reality.de/display/liquid/2013/02/13/Apache+Karaf+Tutorial+Part+8+-+Distributed+OSGi 順便說一句。現在還有Aries RSA提供除CXF之外的快速二進制傳輸。請參閱http://aries.apache.org/modules/rsa.html –