Oracle Service Bus(OSB) Example
2016-01-11 19:51
791 查看
Oracle Service Bus(OSB) Example
本文将使用JDeveloper12C创建一个简单的OSB程序。该程序在OSB中提供了一个天气查询的服务。通过该示例,可以帮助理解OSB中的Proxy Service,Business Service, Pipeline等基本概念,并学习如何创建OSB应用。本文涉及到的工具和系统:
Oracle VirtualBox 5.0.12
Oracle Linux Server 6.7
Oracle JDeveloper12C
Oracle SOA Suite12C
Oracle 网站有供开发人员学习使用的VM下载,VM中已经包含了安装好的SOA Suite和JDeveloper,可用VirtualBox打开直接使用。下载连接: Pre-built Virtual Machine for SOA Suite 12.1.3
基本概念
Proxy ServiceProxy 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调用到外部系统的服务接口中。
在本例中,在OSB中提供了一个查询天气的Proxy Service,而真正提供查询业务逻辑的是Internet上的一个天气查询的Web Service.
创建一个新的Service Bus Project
打开JDeveloper 12C,选择菜单Application-New,在弹出的对话框中选择Service Bus Application with Service Bus Project.Application Name:WeatherServiceBusApplication
Project Name:WeatherServiceBusProject
下载Web Service的WSDL
www.webservicex.ne这个网站提供了一些公共的web Service,这里我们就采用该网站的一个天气查询的web Service来创建我们的示例程序。该web Service的WSDL可以从该URL下载 http://www.webservicex.net/globalweather.asmx?WSDL。首先在项目根目录文件夹下创建一个Wsdls目录。项目所有的WSDL文件都将放到该目录中。然后将下载下来的WSDL文件放到该目录中。
在JDeveloper中查看下载的WSDL文件,可以看到有两个Operation: GetCitiesByCountry和GetWeather。
创建Proxy Service
创建一个Proxy目录。双击打开根目录下的WeatherServiceBusProject,从右边的Components窗口中选择HTTP Service组件,拖动到Design面板的Prxoy Services泳道中,如下图。
JDeveloper会弹出一个对话框,要求输入创建的Proxy Service的属性,Service Name取为WeahterProxyService,Location选择Proxy目录,其余用默认值。
第二步选择我们刚才下载的WSDL文件,Port选择GlobalWeatherSoap
第三步采用缺省值,完成Proxy Service创建
可以看到,Proxy Service生成了,同时生成了一个PipeLine。创建一个Pipeline目录,通过Refactory把WeahterProxyServicePipeline.pipeline移动到Pipeline目录中。
创建Business Service
OSB通过Business Service连接到外部服务。现在我们创建一个Business Service连连接到www.webservicex.ne提供的天气查询服务中。首先在根目录下创建一个存放Business Service的Business目录。
从右边的Components窗口中选择HTTP Service组件,拖动到Design面板的External Services泳道中。
JDeveloper会弹出一个对话框,要求输入创建的Business Service的属性。Service Name取为WeatherBusinessService,Location选择Business目录,其余取缺省值。
这里也选择globalweather.wsdl。globalweather.wsdl,port选择GlobalWeatherSoap。
第三步采用缺省值,可以看到这里已经从WSDL中自动提取出了Endpoint URI。
用鼠标拖动WeatherProxyServicePipeline右端的箭头,连接到WeatherBusinessService上。
打开WeahterProxyServicePipeline.pipeline的Design面板,可以看到Pipeline中增加了一个Route节点,连接到了WeatherBusinessService。如果Proxy Service 和 Business Service的消息格式不一致,还需要在Pipeline中进行消息格式转换。由于本例中的Proxy Service和Business Service采用了同一个WSDL,因此通过Route连接起来即可,不需进行消息转换。
测试
通过JDeveloper部署到到SOA Suite服务器中,然后通过servicebus的管理界面进行测试,在浏览器中打开 http://localhost:7001/servicebus/,选择WeatherServiceBusProject-Proxy-WeatherProxyService,调用该Web Service。查询北京的天气
查询结果
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页
- ORACLE LATERAL-SQL-INJECTION 个人见解