WebSphere Integration Developer 7下开发一个Hello World ESB Java Service
2012-06-22 09:59
148 查看
本文总结了在WebSphere Integration Developer 7下开发一个Hello World ESB Java Service的过程。
第1步 - 创建ESB Java service
1.1) 在WebSphere Integration Developer 7.0 workspace中, 切换到Business Integration Perspective.
1.2) 从文件菜单中, 选择File - New - Module, 输入HelloWorldServiceModule为Module名, 然后点击Finish.
1.3) 在HelloWorldServiceModule工程下, 右键点击Interfaces, 然后选择New - Integerface, 使用HelloWorldInterface为interface名称, 然后点击Finish.
1.4) 在interface编辑器中, 右键点击然后选择Add Request Response Operation, 使用hello为operation名称, 使用message为输入名称,
response为输出名称, 两种同为string类型. 保存所有文件.
1.5) 切换到Assembly Editor, 从Palette中拖拉一个Java部件到Assembly Editor中, 命名为HelloWorldService.
1.6) 右键点击HelloWorldService, 然后选择Add - Interface, 选择HelloWorldInterface.
1.7) 右键HelloWorldService 然后选择Generate Implementation, 新建一个java package
demo.
1.8) 切换到HelloWorldServiceImpl Java编辑器, 使用以下代码实现hello方法, 保存文件.
1.9) 切换到Assembly Editor, 从Palette中拖拉一个References部件到Assembly Editor中.
1.10) 右键点击Stand-alone References, 然后选择Add Reference, 选择HelloWorldInterface
1.11) 连接Stand-alone References到HelloWorldService, 保存文件.
第2步 - 创建ESB客户端
2.1) 切换到Java EE perspective.
2.2) 右键点击HelloWorldServiceModuleWeb工程, 选择New - JSP, 命名为client.jsp, 点击Finish.
2.3) 在client.jsp中使用以下代码, 保存文件.
第3步 - 测试运行程序
3.1) 切换到Business Integration Perspective, 右键点击HelloWorldServiceModule, 选择Export和Integration modules and libraries -
Files for server deployment
3.2) 将生成的EAR文件部署到Websphere Process Server上.
3.3) 使用浏览器访问client.jsp以测试该应用.
第1步 - 创建ESB Java service
1.1) 在WebSphere Integration Developer 7.0 workspace中, 切换到Business Integration Perspective.
1.2) 从文件菜单中, 选择File - New - Module, 输入HelloWorldServiceModule为Module名, 然后点击Finish.
1.3) 在HelloWorldServiceModule工程下, 右键点击Interfaces, 然后选择New - Integerface, 使用HelloWorldInterface为interface名称, 然后点击Finish.
1.4) 在interface编辑器中, 右键点击然后选择Add Request Response Operation, 使用hello为operation名称, 使用message为输入名称,
response为输出名称, 两种同为string类型. 保存所有文件.
1.5) 切换到Assembly Editor, 从Palette中拖拉一个Java部件到Assembly Editor中, 命名为HelloWorldService.
1.6) 右键点击HelloWorldService, 然后选择Add - Interface, 选择HelloWorldInterface.
1.7) 右键HelloWorldService 然后选择Generate Implementation, 新建一个java package
demo.
1.8) 切换到HelloWorldServiceImpl Java编辑器, 使用以下代码实现hello方法, 保存文件.
/** * Method generated to support implementation of operation "hello" defined for WSDL port type * named "HelloWorldInterface". * * Please refer to the WSDL Definition for more information * on the type of input, output and fault(s). */ public String hello(String message) { return "Hello:" + message; }
1.9) 切换到Assembly Editor, 从Palette中拖拉一个References部件到Assembly Editor中.
1.10) 右键点击Stand-alone References, 然后选择Add Reference, 选择HelloWorldInterface
1.11) 连接Stand-alone References到HelloWorldService, 保存文件.
第2步 - 创建ESB客户端
2.1) 切换到Java EE perspective.
2.2) 右键点击HelloWorldServiceModuleWeb工程, 选择New - JSP, 命名为client.jsp, 点击Finish.
2.3) 在client.jsp中使用以下代码, 保存文件.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="com.ibm.websphere.sca.*,commonj.sdo.DataObject" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <body> <% String serviceOutput = "N/A"; String message = request.getParameter("message"); if(message != null){ try{ ServiceManager serviceManager = new ServiceManager(); Service service = (Service) serviceManager.locateService("HelloWorldInterfacePartner"); DataObject respObject = (DataObject) service.invoke("hello", message); serviceOutput = respObject.getString("response"); }catch(Exception e){ e.printStackTrace(); } } %> Service Output : <%= serviceOutput %> <form method="post"> <input type="text" NAME="message"/> <input TYPE="submit" /> </form> </body> </html>
第3步 - 测试运行程序
3.1) 切换到Business Integration Perspective, 右键点击HelloWorldServiceModule, 选择Export和Integration modules and libraries -
Files for server deployment
3.2) 将生成的EAR文件部署到Websphere Process Server上.
3.3) 使用浏览器访问client.jsp以测试该应用.
相关文章推荐
- 使用WebSphere Integration Developer 7开发Business Integration Hello World应用程序
- 使用MyEclipse Web Service来迅速开发和测试一个HelloWorld Web Service,
- JavaWeb集成开发环境IDE配置及HelloWorld.
- 采用CXF框架开发HelloWorld WebService客户端
- eclipse开发java say hello world
- Java系列--第二篇 基于Maven的Android开发HelloAndroidWorld
- 使用 WebSphere Studio Application Developer 集成版,版本 4.1 开发 Java 消息服务应用程序
- Java IDL: The "Hello World" Example Using the POA, a persistent server, and a persistent naming service
- MyEclipse 下开发Java webService 和 Java webClient 的一个完整回调列子
- Java开发环境的准备及"hello world"
- Spring MVC 学习笔记1 - First Helloworld by Eclipse【& - java web 开发Tips集锦】
- 使用 WebSphere Studio Application Developer 开发 Java 程序: 与 VisualAge for Java 进行比较
- axis:开发helloworld webservice
- 开发一个应用程序的思路:"Hello World"
- WebSphere Integration Developer 的SCA模块开发
- 20060507: 视频教程:写一个简单“Hello, world”的Java程序
- 一个简单的Java开发WebService实例
- Windows下AngularJS 和 Git 搭建Angular HelloWorld开发环境
- 菜鸟学Java(十二)——搭建一个完整的Java开发环境
- Java HelloWorld原理分析_动力节点Java学院整理