I have to write a service that can be accessed remotely. I'm using cxf-dosgi-ri-singlebundle-distribution-1.4.0 . So I made the API, then the Implementation, with these properties:
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);
If I deploy the bundle, (after deploying the api and the d-osgi jar) I can see the WSDL in the browser, even from the remote computer. "http://192.168.0.3:9090/preview?wsdl" like this.
But then comes the consumer. There is the OSGI-INF/remote-service/remote-services.xml in the client jar with :
<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>
I can deploy the bundle (after deploying the d-osgi bundle and the API), but I'm always getting back null references. The tutorials always using codes like this
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();
But I'm using Liferay 7, where I can't use this (no constructor for ServiceTracker - I can only get a ServiceTracker instance back from a Registry instance)
The OSGi container is Felix.
I've read it somewhere, that if I can access the WSDL description as seen above, and let's say, there is a method hello() in my API, then a "http://192.168.0.3:9090/preview/hello" call should work... but it doesn't. I don't even know, how to debug this. (Without the remote thing, locally, in the same container, the method call is working)
Any help could come well! Thanks!