java osgi webservice_osgi1——camel与cxf发布webservice

经过三个月的osgi学习,今天打算总结一下osgi与blueprint结合,并且使用camel、cxf等框架去做ESB.

camel是apache下面一个非常著名的框架,定义了一套路由规则,他的根本原理就是,一端进来——处理——另外一端出去,基于这个高度抽象模型,他扩展的范围非常广,可以去整合HTTP,ActiveMQ,JMS,JBI, SCA,MINAorCXF, WD等等。并且实现也非常简单,他可以用spring或者blueprint去简单配置即可使用。

首先先了解下camel与cxf发布webservice

webservice经常用于ESB,如果不用框架自己去实现的话会非常麻烦,所以我们要站在巨人的肩膀上去实现。请看下面blueprint.xml配置

xmlns:camel-cxf="http://camel.apache.org/schema/blueprint/cxf"

xmlns:cxfcore="http://cxf.apache.org/blueprint/core"

xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

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/xmlns/jpa/v1.1.0 http://aries.apache.org/schemas/jpa/jpa_110.xsd

http://aries.apache.org/xmlns/transactions/v1.0.0 http://aries.apache.org/schemas/transaction/transactionv10.xsd

http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd

http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd

http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd"

>

address="http://0.0.0.0:8018/myosgi/camelwebservice"

serviceClass="com.cn.yyc.osgi.imywebservice"

bindingId="http://www.w3.org/2003/05/soap/bindings/HTTP/">

xsi:schemaLocation="http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

${in.header.operationName} == 'test1'

上面配置中serviceClass的配置是一个接口,接口方法中可以定义接受的webservice参数和返回的参数,下面路由节点to到一个资源的时候,可以到很多地方,如果到bean的话,那么类就需要继承org.apache.camel.Processor,实现process方法

import org.apache.camel.Exchange;

import org.apache.camel.Processor;

/**

*

* @author Administrator

*/

public class Test1 implements Processor{

@Override

public void process(Exchange exchange) throws Exception {

Response response=new Response();

exchange.getOut().setBody(response);

}

}

因此pom.xml,文件需要引入依赖

org.apache.camel

camel-core

2.15.1

org.apache.cxf

cxf-core

3.0.4

jar

maven打包成bundle的时候,需要配置如下

org.apache.maven.plugins

maven-compiler-plugin

2.3.2

1.7

1.7

${project.build.sourceEncoding}

org.apache.maven.plugins

maven-source-plugin

2.4

deploy

jar

org.apache.maven.plugins

maven-deploy-plugin

2.8.2

false

org.apache.maven.plugins

maven-javadoc-plugin

2.10.3

true

org.apache.maven.plugins

maven-surefire-plugin

2.7.2

false

org.apache.maven.plugins

maven-jar-plugin

2.3.1

true

lib/

.

yyc

2

${project.groupId}.${project.ArtifactId}

${project.groupId}.${project.ArtifactId}

${project.version}

${project.groupId}

org.osgi.framework,org.slf4j,org.apache.camel,org.apache.cxf.message

可以将打包好的jar包放入servicemix运行,即可拿soapui软件测试

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值