0

リモートでアクセスできるサービスを作成する必要があります。cxf-dosgi-ri-singlebundle-distribution-1.4.0 を使用しています。そこで、次のプロパティを使用して API を作成し、次に実装を作成しました。

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);

バンドルを展開すると (API と d-osgi jar を展開した後)、リモート コンピューターからでもブラウザーで WSDL を確認できます。「http://192.168.0.3:9090/preview?wsdl」のように。

しかし、次に来るのは消費者です。クライアント jar に OSGI-INF/remote-service/remote-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 をデプロイした後) バンドルをデプロイできますが、常に null 参照が返されます。チュートリアルは常にこのようなコードを使用しています

 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インスタンスを取得することしかできません)

OSGi コンテナーは Felix です。

上記のように WSDL の説明にアクセスでき、API にメソッド hello() があり、" http://192.168.0.3:9090/preview/hello " 呼び出しは機能するはずですが、機能しません。これをデバッグする方法もわかりません。(リモートのものなしで、ローカルで、同じコンテナ内で、メソッド呼び出しが機能しています)

どんな助けでもうまくいく可能性があります!ありがとう!

4

3 に答える 3

0

より簡単な解決策は、Zookeeper ベースのディスカバリーを使用することです。サーバー ノードは、エクスポートしたサービスを ZooKeeper に公開し、コンシューマ ノードは、バンドルがそのようなサービスを要求するとすぐに、これらの OSGi サービスをすぐに使用できるように作成します。

于 2016-04-26T09:55:24.673 に答える
0

Apache CXF に基づく Liferay SOAP Extender を使用する必要があります。Liferay Developer Network の例が見つかります。

于 2016-10-03T22:48:57.667 に答える