`

servicemix 7安装使用及camel-cxf代理webservice

 
阅读更多
前述:之前用servicemix3通过jbi代理webservice。由于smx版本升级较快,smx7已经弃用了jbi,转而通过camel转换协议。

servicemix 3安装及cxf-bc组件代理webservice服务
http://newjava-sina-cn.iteye.com/blog/2357092

这边文章主要是学习通过camel代理ws的学习过程。


1.安装使用servicemix7

2.camel-cxf代理webservice

3.常用命令





1.安装使用servicemix7
下载servicemix:
http://servicemix.apache.org/downloads/servicemix-7.0.0.M2.html

解压到某个路径下,如:D:\service\apache-servicemix-7.0.0.M2

配置系统变量 SERVICEMIX_HOME=D:\service\apache-servicemix-7.0.0.M2

进入bin目录下,运行servicemix.bat便可启动servicemix



通过console shell,可以查看特性或控制servicemix,如:
bundle:list                    显示已安装的组件
bundle:list | grep camel       查找特定组件
log:display                    查看日志
log:display | grep DEBUG       查找debug日志
log:set INFO                   设置日志级别
feature:list                   查看特性(包括已安装和未安装)
feature:list | grep camel      查看感兴趣的特性

feature:install webconsole     安装web控制台

安装成功后,访问http://localhost:8181/system/console smx/smx。通过web页面,可以启动或停止组件,安装原有feature等。

由于安装一些组件可能要从maven库下载依赖的jar包,网速较慢。可以将maven库改成国内的(etc/org.ops4j.pax.url.mvn.cfg for the org.ops4j.pax.url.mvn.repositories)






2.camel-cxf代理webservice
在eclipse新建一个普通的maven project项目(根据maven-archetype-quickstart原型)

在src/main/resources源文件下新建META-INF/spring/camel-config.xml(smx7能够识别的结构)。

配置camel-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
 
  <!-- this is the CXF web service we use as the front end -->
  <cxf:cxfEndpoint id="reportIncident"
                   address="http://0.0.0.0:8186/camel_0319_cxf/camel/CXF_HELLO_ObjectSpringService/IHello"
                   serviceName="s:HelloWorldService"
                   endpointName="s:HelloWorld" 
                   wsdlURL="http://localhost:8081/HelloWorld/services/HelloWorld?wsdl"
                   xmlns:s="http://ws.bill.com"/>
 
  <!-- this is the Camel route which proxies the real web service and forwards SOAP requests to it -->
  <camelContext xmlns="http://camel.apache.org/schema/spring">
 
    <!-- <endpoint id="callRealWebService" uri="http://localhost:${real.port}/real-webservice?throwExceptionOnFailure=false"/> --><!-- &amp; -->
    <endpoint id="callRealWebService" uri="http://localhost:8081/HelloWorld/services/HelloWorld?bridgeEndpoint=true"/>
 
    <route>
      <!-- CXF consumer using MESSAGE format -->
      <from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/> <!-- ?dataFormat=MESSAGE -->
      <setHeader headerName="SOAPAction" >
          <constant>FooSync</constant>
      </setHeader>
      <convertBodyTo type="String" />
      <!-- log input received -->
      <to uri="log:input?showHeaders=true"/>
      <!-- enrich the input by ensure the incidentId parameter is set -->
      <!-- <to uri="bean:enrichBean"/> -->
      <!-- Need to remove the http headers which could confuse the http endpoint -->
      <!-- <removeHeaders pattern="CamelHttp*"/> -->
      <!-- send proxied request to real web service -->
      <to ref="callRealWebService"/>
      <convertBodyTo type="String" />
      <!-- log answer from real web service -->
      <to uri="log:output?showHeaders=true"/>
    </route>
 
  </camelContext>
 
</beans>


注意事项:
a.该配置是根据camel官方实例(http://camel.apache.org/cxf-proxy-example.html)改造而来(见附件camel-example-cxf-proxy-2.11.1-sources.jar.7z),根据自己服务器地址设置callRealWebService的endpoint.uri

b.配置cxf:cxfendpoint端点时,xmlns:s应为自己的webservice的命令空间,wsdlUrl文件中的targetNamespace="http://ws.bill.com"。serviceName为服务的服务名,endpointName为服务的端口名

c.对于axis的ws,如果请求头部没有soapAction,则会报no soapAction header类似错误,cxf的ws不会有这个问题,可以去掉这个配置

d.读者可查询相关资料,调试route中的相关组件


配置完成后,右键项目run as - maven install 生成组件,在target文件夹下生成一个jar包,放到smx7的deploy文件夹下,自动部署完成

日志data/log/servicemix.log

访问http://localhost:8186/camel_0319_cxf/camel/CXF_HELLO_ObjectSpringService/IHello?wsdl
或通过soap-ui测试



改造实例源码,附件处可下载



3.常用命令
log:display   显示日志

feature:install camel-http





参考网站:
http://camel.apache.org/cxf-proxy-example.html

https://access.redhat.com/documentation/en-US/Fuse_ESB_Enterprise/7.0/html-single/Web_Services_and_Routing_with_Camel_CXF/index.html#Proxying-HTTP

  • 大小: 47.8 KB
  • 大小: 111.2 KB
分享到:
评论

相关推荐

    servicemix 3安装及cxf-bc组件代理webservice服务

    【标题】:“Servicemix 3安装及CXF-Bundle Component代理WebService服务” 在本文中,我们将深入探讨Apache Servicemix 3的安装过程以及如何使用CXF-Bundle Component来代理WebService服务。Apache Servicemix是...

    Camel-CXF-CXFRS-Demo

    蓝图的骆驼路由器项目 (OSGi) 要构建此项目,请使用 mvn install要运行该项目,您可以执行以下 Maven 目标 mvn camel:run在 OSGi 中部署项目。 例如使用 Apache ServiceMix 或 Apache Karaf。 您可以从其 shell 运行...

    apache-cxf-3.3.4

    XF支持的特性非常广泛,但特性主要在以下一些方面: 支持的Web服务标准包括: SOAP ...ServiceMix或其他JBI容器 Geronimo或其他Java EE容器 Tomcat或其他Servlet容器 OSGi 引用OSGi远程服务实现

    org.apache.servicemix.bundles.spring-jdbc-3.2.8.RELEASE_2.zip

    1. **Apache ServiceMix**:了解 ServiceMix 如何作为 ESB(企业服务总线)工作,以及如何使用其集成的组件,如 Spring、CXF 和 Camel,来构建和管理 SOA(面向服务架构)应用程序。 2. **Spring JDBC**:理解 ...

    CXF-WebService-开发指南、技术文档.docx

    【CXF WebService 开发指南】 CXF(Commons eXtensible Framework)是一个开源的Java框架,主要用于构建和开发Web服务。它提供了强大的服务实现和客户端调用能力,支持多种协议和规范,如JAX-WS、JAX-RS等。本指南...

    camel-manual-1.5.0.pdf

    1. **URI驱动**:Apache Camel通过使用URI来定义路由路径,使得开发者能够轻松地配置和管理不同的传输协议和消息处理模型。 2. **轻量级**:该框架具有很小的内存占用,并且对外部依赖的要求很低,这使其非常适合...

    WebService-CXF学习.doc

    接着,你可以编写一个简单的 Java 类,定义服务接口和实现,使用 CXF 提供的工具生成相应的 WSDL 文件,并配置服务发布和客户端调用。这个过程演示了如何使用 CXF 创建、部署和调用 Web 服务。 总之,Apache CXF 是...

    apache-camel-2.7.1-fuse-00-27

    Fuse ESB是基于Apache ServiceMix的轻量级企业服务总线(ESB),它提供了一组全面的中间件服务,包括消息传递、服务代理、事务处理和安全管理等。Fuse ESB集成了Apache Camel,利用其强大的路由和集成能力,使得...

    org.apache.servicemix.bundles.elasticsearch-1.0.1_1.zip

    标题中的"org.apache.servicemix.bundles.elasticsearch-1.0.1_1.zip"表明这是一个与Apache ServiceMix相关的软件包,特别地,它包含了Elasticsearch的一个特定版本(1.0.1)的bundle。Apache ServiceMix是基于Java...

    apache-camel-demo

    apache-camel 开发sample Apache Camel是一个基于规则路由和中介引擎,提供企业集成模式的Java对象(POJO)的...在面向服务的体系结构的项目中,Camel通常与Apache ServiceMix, Apache ActiveMQ以及Apache CXF一同使用。

    servicemix代理web service

    - 安装Servicemix和CXF组件。 - 使用CXF工具生成服务客户端或服务器端代码。 - 配置Servicemix的XML配置文件,指定服务代理的行为。 - 将服务部署到Servicemix,通过命令行或管理界面启动服务。 - 测试代理服务...

    servicemix-cxf-jaxrs-blueprint-example

    jar文件MANIFEST文件中的Import-Packages排序需要修改,应为以下内容 导入包:javax.xml.bind.annotation,javax.ws.rs; version =“ [2.0,3)”,javax.ws.rs.core; version =“ [2.0,3)”,org.apache。...

    camel-manual-2.8.0

    根据给定文件的信息,我们可以深入探讨Apache Camel 2.8.0版本中涵盖的关键知识点,这一版本是Apache Camel集成框架的重要里程碑,它基于已知的企业集成模式(Enterprise Integration Patterns),并具备强大的Bean...

    camel-manual-2.4.0, 用户手册

    - **安装和设置**:介绍如何安装 Apache Camel 并将其设置为开发环境的一部分。 - **基本概念**:解释 Apache Camel 的核心概念,包括路由、处理器、端点等。 - **开发第一个应用程序**:指导用户通过一个简单的示例...

    org.apache.servicemix.bundles.spring-test-3.2.8.RELEASE_2.zip

    Apache ServiceMix是基于Java的全面企业级服务总线(ESB),它集成了许多开放源代码Java技术,如Spring、CXF和ActiveMQ等。而"spring-test"模块则是Spring框架的一部分,用于支持对Spring应用进行单元测试和集成测试...

    camel-manual-2.0

    ### Apache Camel 2.0: An In-depth Overview #### Introduction Apache Camel 2.0 is an advanced integration framework that implements Enterprise Integration Patterns (EIP) in a robust and flexible ...

Global site tag (gtag.js) - Google Analytics