0

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!

3 Answers3

0

A simpler solution would be to use the zookeeper based discovery. The server node will publish the services it exports to zookeeper and the consumer node will create ready to use OSGi services for these as soon as a bundle requests such a service.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • So in this case, the client won't need any remote-services.xml? – Csaba Turcsán Apr 27 '16 at 20:32
  • Exactly. See this tutorial for more details http://liquid-reality.de/display/liquid/2013/02/13/Apache+Karaf+Tutorial+Part+8+-+Distributed+OSGi Btw. there is now also Aries RSA which provides a fast binary transport besides the CXF one. See http://aries.apache.org/modules/rsa.html – Christian Schneider Apr 27 '16 at 22:18
0

Riena Communication its less complicated for publishing and binding remote services. It uses hessian as communication protocol. its really fast in comparison to soap, since its binary based protocol (not xml)

I hope this helps.

Hisham Khalil
  • 1,054
  • 8
  • 9
0

You should use the Liferay SOAP Extender that based on Apache CXF. You will find an example to the Liferay Developer Network.

Antonio Musarra
  • 370
  • 1
  • 14