【问题标题】:How to configure CXF JAX-WS server with Blueprint如何使用蓝图配置 CXF JAX-WS 服务器
【发布时间】:2012-09-26 18:28:32
【问题描述】:

我想将一个简单的 CXF Jax-Ws 服务器部署到 ServiceMix。它只是一个同时具有服务接口和 impl 类的 OSGI 包。我需要将它部署到不同的 ServiceMix 服务器(版本 4.4.1),所以我需要更改每个服务器的 URL 地址。我想在 Karaf .cfg 文件中进行特定于服务器的配置,其余的在蓝图中进行。这不需要骆驼。我应该在蓝图中做什么?我找不到具体的文档。

【问题讨论】:

  • 你有没有尝试过?
  • 为什么我做到了。我有一个没有 osgi 的 Web 服务。我现在正在使用 Spring 将其转换为 osgi。
  • 那么问题出在哪里?您有一个 Web 服务,是什么阻止您将其转换为 OSGi?我已经完成了从 Web 服务到 OSGi 的转换,并成功地将它们部署到了 Karaf 中。我需要有关您的问题的更多详细信息,然后才能为您提供帮助。
  • Web 服务使用 Maven 包插件构建,它通过了 Eclipse 中的 JUNit 测试,我在 Karaf 中部署和解析包。接下来我需要启动和停止 Web 服务。我第一次尝试了 BundleActivator,奇怪的是,当我添加 osgi.core Maven 依赖项时,Eclipse 仍然找不到 BundleActivator 类。我更喜欢使用声明式服务来做到这一点,但我找不到任何关于如何做到这一点的 ServiceMix 文档。我的下一个选择是 Blueprint,但我还没有找到关于如何将它用于同时具有 SEI 和 Impl 的捆绑包的文档。

标签: cxf jax-ws apache-karaf apache-servicemix blueprint-osgi


【解决方案1】:

我有一个tutorial about CXF and blueprint in Apache Karaf。这应该为您提供了一个完整的示例。

【讨论】:

    【解决方案2】:

    包括我用来在 Karaf 中使用 CXF 和蓝图配置“一体式”JAX-WS Web 服务的蓝图配置。

    我还包括了特定于服务器的属性(在 OSGi Config Admin 中定义)。 Karaf 的etc 目录中的 .cfg 文件将命名为 com.example.myservice.cfg,并且可以在带有 ${} 符号的蓝图文件中访问它们。我定义了一个名为schema-validation-enabled 的属性(我们为生产环境切换了这个值)。

    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
    xmlns:cxf="http://cxf.apache.org/blueprint/core"
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
    
    xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                        http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.0.0.xsd
                        http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
                        http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">
    
    <cm:property-placeholder persistent-id="com.example.myservice">
        <cm:default-properties>
            <cm:property name="schema-validation-enabled" value="true"/>
        </cm:default-properties>
    </cm:property-placeholder>
    
    <!-- A normal CXF endpoint -->
    <jaxws:endpoint id="sampleService" implementor="com.example.myservice.impl.MyServiceImpl"
        endpointName="s:MyServicePort" serviceName="s:MyService" address="/MyService"
        wsdlLocation="/wsdl/MyService.wsdl"
        xmlns:s="http://www.example.com/MyService/SVC/v1">
        <jaxws:properties>
            <entry key="schema-validation-enabled" value="${schema-validation-enabled}" />
        </jaxws:properties>
    </jaxws:endpoint>
    

    【讨论】:

      【解决方案3】:

      我也遇到了同样的问题,这是因为服务所属的捆绑包的 OSGi 蓝图中缺少 bean 定义。 我意识到即使 bean ref 定义存在于 using Service 的捆绑包的 OSGi 蓝图中,也必须在它自己的捆绑蓝图中定义它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-09
        • 2011-03-28
        • 2012-12-24
        相关资源
        最近更新 更多