我必须编写一个可以远程访问的服务。 我正在使用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 –