oracle bus,Oracle Service Bus(OSB) Example

http://blog.csdn.net/zhaohuabing/article/details/50499264

Oracle Service Bus(OSB) Example

本文将使用JDeveloper12C创建一个简单的OSB程序。该程序在OSB中提供了一个天气查询的服务。通过该示例,可以帮助理解OSB中的Proxy Service,Business Service, Pipeline等基本概念,并学习如何创建OSB应用。

本文涉及到的工具和系统:

VirtualBox 5.0.12

Server 6.7

Oracle JDeveloper12C

Oracle SOA Suite12C

Oracle 网站有供开发人员学习使用的VM下载,VM中已经包含了安装好的SOA Suite和JDeveloper,可用VirtualBox打开直接使用。下载连接:

基本概念

Proxy Service

Proxy services are Oracle Service Bus definitions of intermediary Web services that Oracle Service Bus implements locally on Oracle WebLogic Server.

Business Service

Business services describe the enterprise services that exchange messages with business processes and which we want to virtualize using the OSB.

Proxy Service是在OSB中创建的一个web serverice,Business Service则代表了集成到OSB中的业务逻辑,Business Service会连接到一个外部的业务服务。客户端调用Proxy Service提供的服务接口,Prxoy则会通过Business Service调用到外部系统的服务接口中。

161ccadbcb5b1c816892a954758b8361.png 

在本例中,在OSB中提供了一个查询天气的Proxy Service,而真正提供查询业务逻辑的是Internet上的一个天气查询的Web Service.

创建一个新的Service Bus Project

打开JDeveloper 12C,选择菜单Application-New,在弹出的对话框中选择Service Bus Application with Service Bus Project.

bedba9dede9f2112549c9468fa1b5de7.png 

Application Name:WeatherServiceBusApplication

Project Name:WeatherServiceBusProject

下载Web Service的WSDL

这个网站提供了一些公共的web Service,这里我们就采用该网站的一个天气查询的web Service来创建我们的示例程序。该web Service的WSDL可以从该URL下载 。

首先在项目根目录文件夹下创建一个Wsdls目录。项目所有的WSDL文件都将放到该目录中。然后将下载下来的WSDL文件放到该目录中。

在JDeveloper中查看下载的WSDL文件,可以看到有两个Operation: GetCitiesByCountry和GetWeather。

3a482e959c750fff1815166f9ce02409.png

创建Proxy Service

创建一个Proxy目录。

双击打开根目录下的WeatherServiceBusProject,从右边的Components窗口中选择HTTP Service组件,拖动到Design面板的Prxoy Services泳道中,如下图。

b54cb9fd6cc422f84663910b1a0c2f9a.png

JDeveloper会弹出一个对话框,要求输入创建的Proxy Service的属性,Service Name取为WeahterProxyService,Location选择Proxy目录,其余用默认值。

e980c1f730d1ac6ff1c8cd6569581fb5.png

第二步选择我们刚才下载的WSDL文件,Port选择GlobalWeatherSoap

025c3251ee3d589a65eff45074348881.png 

第三步采用缺省值,完成Proxy Service创建

ec03fda74c3ace78f88e26bcecb41999.png 

可以看到,Proxy Service生成了,同时生成了一个PipeLine。创建一个Pipeline目录,通过Refactory把WeahterProxyServicePipeline.pipeline移动到Pipeline目录中。

eee9d2e6b92863ae45ff6bf4f57735a8.png

创建Business Service

OSB通过Business Service连接到外部服务。现在我们创建一个Business Service连连接到提供的天气查询服务中。

首先在根目录下创建一个存放Business Service的Business目录。

从右边的Components窗口中选择HTTP Service组件,拖动到Design面板的External Services泳道中。

69538f98a32620fe99e6f75211e31a82.png

JDeveloper会弹出一个对话框,要求输入创建的Business Service的属性。Service Name取为WeatherBusinessService,Location选择Business目录,其余取缺省值。

b6e4665d60b328644cbab6ea6511e829.png

这里也选择globalweather.wsdl。globalweather.wsdl,port选择GlobalWeatherSoap。

68e71c049fe841df93729830cbac5d50.png

第三步采用缺省值,可以看到这里已经从WSDL中自动提取出了Endpoint URI。

1b1df842635d76b3439f5ff1c221c567.png 

用鼠标拖动WeatherProxyServicePipeline右端的箭头,连接到WeatherBusinessService上。

7d70d51e0edc9a9803168feeb412ecaa.png 

打开WeahterProxyServicePipeline.pipeline的Design面板,可以看到Pipeline中增加了一个Route节点,连接到了WeatherBusinessService。如果Proxy Service 和 Business Service的消息格式不一致,还需要在Pipeline中进行消息格式转换。由于本例中的Proxy Service和Business Service采用了同一个WSDL,因此通过Route连接起来即可,不需进行消息转换。

3c7f48eb0bd0ee101ad98c7f2b2a3f97.png

测试

通过JDeveloper部署到到SOA Suite服务器中,然后通过servicebus的管理界面进行,在浏览器中打开 ,选择WeatherServiceBusProject-Proxy-WeatherProxyService,调用该Web Service。

查询北京的天气

d3b663373ce0f0f253364ab1375c236d.png 

查询结果

309c3bcd8ed95aa0708f9fedfb8a7c0a.png

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值