【问题标题】:Websphere 8.5 + CXF in OSGi bundle. Is it possible?OSGi 包中的 Websphere 8.5 + CXF。是否可以?
【发布时间】:2015-04-13 11:48:07
【问题描述】:

我正在为基于 Websphere 8.5 和 OSGi 的设计编写 PoC。

我需要让 SOAP Web 服务将我们作为 OSGi 包运行,并使用应用程序中其他 OSGi 包公开的 OSGi 服务。

我一直在尝试在 OSGi 包中获取 JAX-WS 服务。

到目前为止我尝试了什么:

  1. 让普通 servlet 作为 OSGi 包运行(有效)
  2. 让 JAX-RS 服务作为 OSGi 包运行(有效)
  3. 使用 Websphere 提供的 JAX-WS 运行时让 JAX-WS 服务作为 OSGi 包运行。这似乎不适用于从 JAX-WS 运行时抛出的异常
  4. 让 JAX-WS 服务作为 OSGi 包运行会禁用 Websphere 提供的 JAX-WS 运行时并尝试将 CXF2 运行时嵌入到 OSGi 包中。不适用于从 JAXB 抛出的异常(某种类冲突)。

在我过多解释异常等之前。有人对将 JAX-WS 服务部署为 Websphere 8.5 中的 OSGi 包感到高兴吗?在 Karaf 中有关于这样做的资源,但我仅限于 Websphere。

【问题讨论】:

  • 询问您的 IBM 支持代表不是更好吗?

标签: web-services websphere osgi cxf jax-ws


【解决方案1】:

回答我自己的问题,

似乎不支持从 OSGi 包中创建 JAX-WS 服务的方式与 Servlet 和 REST 服务相同。

编辑: 以上说法不实,请看WASDEV forum上的贴子。尽管对于 OSGi 和 SCA,这个答案的其余部分仍然有效(尽管 SCA 的服务似乎是用 Axis2 而不是 CXF 实现的)

支持的是使用 SCAOSGi 服务 公开为 SOAP 服务。

这个答案的其余部分假设:

  1. 您有一个 OSGi 应用程序,其中一个捆绑包通过 blueprint.xml 公开了您希望通过 SOAP 公开的服务。
  2. 您拥有没有 SCA 工具的 Eclipse IDE。
  3. 您拥有带有 Websphere 工具的 Eclipse IDE(为您提供 OSGi 工具)
  4. 您可以访问 WAS 控制台 Web 应用程序

这些是通过 SOAP Web 服务访问服务所需的步骤

准备 OSGi 应用程序

  1. 在 OSGi 应用程序项目的 APPLICATION.MF 中,使用 Application-ExportService 标头标记服务接口: Application-ExportService: service.ExternalService
  2. 在包含服务的 OSGi 捆绑包的 blueprint.xml 文件中,添加 <entry key="service.exported.interfaces" value="*"/> 属性,例如:

<service id="externalService" ref="externalServiceBean" interface="ccb.service.ExternalService"> <service-properties> <entry key="service.exported.interfaces" value="*"/> </service-properties> </service>

  1. 将项目导出为 EBA

准备 SCA 工件

  1. 创建一个具有以下结构的 Java 项目

/service.composite /META-INF/sca-contribution.xml

  1. sca-contribution.xml 可能如下所示:

<?xml version="1.0" encoding="UTF-8"?> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"> <deployable xmlns:ns1="http://www.example.com" composite="ns1:ServiceComposite" /> </contribution>

  1. service.composite 可能如下所示:

    <?xml version="1.0" encoding="UTF-8"?> <composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:scafp="http://www.ibm.com/xmlns/prod/websphere/sca/1.0/2007/06" targetNamespace="http://www.example.com" name="ServiceComposite"> <component name="ServiceComponent"> <scafp:implementation.osgiapp applicationSymbolicName="[Your OSGi Application name]" applicationVersion="1.0.0" /> <service name="[maching the ID of the service in the blueprint.xml]"> <binding.ws /> </service> </component> </composite>

  2. 将项目导出为 jar

通过 WAS 控制台部署全部

  1. 创建新的空 BLA

应用程序 -> 应用程序类型 -> 业务级应用程序 -> 新

  1. 将 EBA 和 SCA jar 部署为资产

应用程序 -> 应用程序类型 -> 资产 -> 导入

  1. 首先添加 EBA,然后将 SCA jar 添加到业务级应用的已部署资产

应用程序 -> 应用程序类型 -> 业务级应用程序 -> [您的应用程序] -> 添加(在“已部署的资产”下)

你已经完成了!您应该在服务器的日志中看到端点 url

资源:

http://ianrobinson.blogspot.co.uk/2010/05/osgi-and-sca-come-together-in-websphere.html

http://www-01.ibm.com/support/knowledgecenter/SSEQTP_8.5.5/com.ibm.websphere.osgi.doc/ae/ca_sca.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多