Creating a RESTful Web Service for IMS-Transaction



Similar documents
JBoss SOAP Web Services User Guide. Version: M5

Hello World RESTful web service tutorial

Building and Using Web Services With JDeveloper 11g

This presentation will provide a brief introduction to Rational Application Developer V7.5.

CREATE A CUSTOM THEME WEBSPHERE PORTAL

Create a Web Service from a Java Bean Test a Web Service using a generated test client and the Web Services Explorer

Module 13 Implementing Java EE Web Services with JAX-WS

Creating Web Services Applications with IntelliJ IDEA

WA2087 Programming Java SOAP and REST Web Services - WebSphere 8.0 / RAD 8.0. Student Labs. Web Age Solutions Inc.

CONFIGURATION AND APPLICATIONS DEPLOYMENT IN WEBSPHERE 6.1

T320 E-business technologies: foundations and practice

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Exam Name: IBM InfoSphere MDM Server v9.0

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

IBM WebSphere Adapter for FTP OutBound operation for SFTP protocol using public key authentication.

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

IBM WebSphere Adapter for PeopleSoft Enterprise Quick Start Tutorials

Accessing Data with ADOBE FLEX 4.6

Deploying Intellicus Portal on IBM WebSphere

Witango Application Server 6. Installation Guide for Windows

Tutorial: Building a Dojo Application using IBM Rational Application Developer Loan Payment Calculator

Tutorial Build a simple IBM Rational Publishing Engine (RPE) template for IBM Rational DOORS

WEB SERVICES. Revised 9/29/2015

IBM WebSphere Application Server Communications Enabled Applications Setup guide

Java EE 6 development with Eclipse, Netbeans, IntelliJ and GlassFish. Ludovic Champenois Oracle Corporation

IBM InfoSphere MDM Server v9.0. Version: Demo. Page <<1/11>>

WebSphere Application Server V7: Deploying Applications

IBM Business Monitor V8.0 Global monitoring context lab

IBM WebSphere Application Server

IBM Tivoli Workload Scheduler Integration Workbench V8.6.: How to customize your automation environment by creating a custom Job Type plug-in

Developing an EJB3 Application. on WebSphere 6.1. using RAD 7.5

1. Tutorial Overview

IBM Rational Rapid Developer Components & Web Services

To begin, visit this URL:

Instant Chime for IBM Sametime Installation Guide for Apache Tomcat and Microsoft SQL

IUCLID 5 Guidance and Support

Working with WebSphere 4.0

Oracle EXAM - 1Z Java EE 6 Web Services Developer Certified Expert Exam. Buy Full Product.

Developing Web Services Applications

WebSphere Training Outline

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

Exam Name: IBM WebSphere Process Server V6.2,

Configuring Situation Events in Action Manager for WebSphere Business Monitor Version 6.0

Creating Java EE Applications and Servlets with IntelliJ IDEA

Overview of Web Services API

Install guide for Websphere 7.0

By Wick Gankanda Updated: August 8, 2012

NetBeans IDE Field Guide

Creating your first Web service and Web application

Configuring Secure Socket Layer (SSL) for use with BPM 7.5.x

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

WebSphere Server Administration Course

ITG Software Engineering

Enhanced Connector Applications SupportPac VP01 for IBM WebSphere Business Events 3.0.0

IBM WebSphere Server Administration

Web services with WebSphere Studio: Deploy and publish

Rational Application Developer Performance Tips Introduction

Business Process Management IBM Business Process Manager V7.5

Glassfish, JAVA EE, Servlets, JSP, EJB

Practice Fusion API Client Installation Guide for Windows

Developing Web Services with Apache CXF and Axis2

Implementing the Shop with EJB

Novell Identity Manager

Building Web Services with Apache Axis2

Consuming and Producing Web Services with WST and JST. Christopher M. Judd. President/Consultant Judd Solutions, LLC

Red Hat JBoss Developer Studio 7.0 JBoss SOAP Web Services User Guide

Architectural Overview

Building Java Servlets with Oracle JDeveloper

CREATING AND DEPLOYING ABL WEB SERVICES

Oracle Hyperion Financial Management Developer and Customization Guide

Consuming and Producing Web Services with Web Tools. Christopher M. Judd. President/Consultant Judd Solutions, LLC

BPM Scheduling with Job Scheduler

Tutorial: BlackBerry Application Development. Sybase Unwired Platform 2.0

Automatic updates for Websense data endpoints

Realizing Enterprise Integration Patterns in WebSphere

IBM WebSphere Adapter for Quick Start Tutorials

Securing SAS Web Applications with SiteMinder

Enterprise Content Management System Monitor. How to deploy the JMX monitor application in WebSphere ND clustered environments. Revision 1.

Getting Started with Amazon EC2 Management in Eclipse

A Java proxy for MS SQL Server Reporting Services

Siebel Store-and-Forward Messaging Guide for Mobile Web Client. Siebel Innovation Pack 2013 Version 8.1/8.2 September 2013

Data Sheet VISUAL COBOL WHAT S NEW? COBOL JVM. Java Application Servers. Web Tools Platform PERFORMANCE. Web Services and JSP Tutorials

Configuring Load Balancing

IBM WebSphere Application Server V8.5 lab Basic Liberty profile administration using the job manager

Converting Java EE Applications into OSGi Applications

Redpaper Axel Buecker Kenny Chow Jenny Wong

Oracle WebLogic Server

PASS4TEST 専 門 IT 認 証 試 験 問 題 集 提 供 者

Oracle Hyperion Financial Management Custom Pages Development Guide

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Flexible Decision Automation for Your zenterprise with Business Rules and Events

WebSphere Business Monitor

Oracle Service Bus Examples and Tutorials

Drupal CMS for marketing sites

Creating a Web Service using IBM Rational HATS. For IBM System i (5250) Creating a Web Service using HATS 1

Business Interaction Server. Configuration Guide Rev A

IBM WEBSPHERE LOAD BALANCING SUPPORT FOR EMC DOCUMENTUM WDK/WEBTOP IN A CLUSTERED ENVIRONMENT

Transcription:

Creating a RESTful Web Service for IMS-Transaction Author: Ivy Ho (ivyho@ca.ibm.com), Advisory Software Engineer, J2C Team Lead, IBM Editor: Virginia Lovering (lovering@ca.ibm.com), Information Specialist, IBM Introduction The Java API for R ESTful Web Services (JAX-RS), also known as JSR-311, is a programming model that allows you to create Representational State Transfer (REST) services quickly. In this tutorial, we will guide you through the steps to create a RESTful Web Services to retrieve phone book information based on a last name from the IMS server. Any JAX-RS v1.1 implementation can be used, but for this tutorial we will be using the IBM implementation which is installed when you install a v7 WebSphere Test Environment. Software Requirements Rational Application Developer V7.5.5.x or later. Optional Features required: Java EE Connector (J2C) Development Tools WebSphere Application Server V7.0 Test Environment Web 2.0 V1.0.1 feature pack Other Requirements The phone book COBOL book sample is installed on the IMS system.

Learning Objectives In this tutorial, you will learn to: Create a J2C application using the J2C Bean wizard for processing a IMS transaction. Enable the JAX-RS in the J2C bean project for a IMS transaction. Deploy and Test the JAX-RS web service to retrieve phone book addresses. Create a J2C bean application for an IMS transaction The following describes how to use the J2C Java bean wizard to build a JAX-RS enabled dynamic web application that processes an IMS IM transaction and returns a phone book record. We are using the non-managed connection and we are connecting directly to the IMS server.

Select a Resource Adapter 1. Import Resource Adapter and Create a connector project. 2. Select File -> J2C -> J2C Bean. 3. Select the IMS TM Resource adapter: 3. Specify the connector project name. 4. Select a target server, and click Next:

5. On the Adapter Style Page, click Outbound: 6. On the Scenario Selection page, click IMS COBOL, PL/1 or C-based applications:

7. On the Connection Properties page a. clear Managed Connection b. select Non-Managed Connection c. and enter the connection information: Create a JAX-RS enabled Dynamic Web Project The following steps describe how to create the J2C bean in a JAX_RS enabled dynamic web project. The steps are very similar to the steps to create a typical J2C bean. The only difference is the extra configuration when you create the dynamic Web Project. 1. Enter Web Project Name and click New:

2. On the New Source Project Creation page, select Web Project and click Next: 3. 3. On the New Dynamic Web Project page, a. Select the target runtime server. b. Accept the default web module version. c. Under Configuration, select IBM JAX-RS Configuration. This will add the JAX-RS 1.1, Ajax Proxy, and Server-side technologies facets. The facet adds the library, servlet information, and support for JAX-RS annotations processing and JAX-RS quick-fixes d. Select add Project to an EAR in the EAR membership, and click Next:

4 On the Web Module page, click Generate web.xml deployment descriptor, and click Next:

5. On the Web 2.0 Server-Side Technologies page, accept the default, and click Next: 6. On the JAX-RS Capabilities page, in the Library field select the library for your server version, for example IBM WebSphere JAX-RS Library for WAS 7. Click Include library with this application and select to include it as a Shared Library. Click Finish:

7. On the J2C bean Output Properties page, specify Package name, Interface class name and Implementation name for the J2C bean. In the Implementation name field, by default, the name appears as < interface name>impl. 8. On the Add Java method page, beside the Input type field, click New:

9. On the Data Import page, click Browse and select the COBOL copy book. Click Next: 10. In the Saving properties page, select the following values for input type: a. Select Default for Generation Style. b. Click Browse beside the Project Name and choose the Web project IMSWebPhoneBook. c. In the Package Name field, type sample.ims.data. d. In the Class Name field, accept the default INPUTMSG. Click Finish.

11. In the COBOL Importer page, click Show Advanced. Select these options: a. Select the options in the following table: COBOL Importer Parameter Settings Parameter Platform Name Codepage Floating point format name External decimal sign Endian name Remote integer endian name Quote name Trunc name Nsymbol name b. Click Query to load the data. Value Z/OS IBM-037 IBM Hexadecimal EBCDIC Big Big DOUBLE STD DBCS c. A list of data structures from the Ex01.cbl file is shown. Select OUTPUT-MSG in the Data structures field, and click Next:

12. In the Saving Properties page, a. Select Default for Generation Style. b. Click Browse beside the Project Name and choose the Web project IMSWebPhoneBook. c. In the Package Name field, type sample.ims.data. d. In the Class Name field, accept the default OUTPUTMSG. Click Finish.

12. Click Finish to complete the J2C bean creation and generate all the artifacts. You will see the following artifacts in the Web Project: J2C bean interface phone book.java J2C bean Implementation phone bookimpl.java Data Binding files INPUTMSG.java OUTPUTMSG.java

Introspecting the phone book Imp.java The connection information is generated as values for the @j2c.managedconnectionfactory doclets The connection values will be used in the initializebinding method to connection to the IMS system directly.

Create Sample Applications Create the Sample PhonebookRS.java and PhonebookRSApplication.java into the sample.ims package of project IMSWebRSProject. PhonebookRSApplication.java package sample.ims; import java.util.hashset; import java.util.set; import javax.ws.rs.core.application; public class PhoneBookRSApplication extends Application { } @Override public Set<Class<?>> getclasses() { Set<Class<?>> classes = new HashSet<Class<?>>(); classes.add(phonebookrs.class); return classes; } PhoneBookRS.java - Define a list which is an array of LAST names. The Last Name is the key to the PhoneBook record In the getlist method, it will invoke the getphonebook method in the J2C bean to retrieve the phone book record from the backend IMS system. The output phonebook record contains extensions, zips, name1 and name2. PhonebookRS.java package sample.ims;

import javax.resource.resourceexception; import javax.ws.rs.get; import javax.ws.rs.post; import javax.ws.rs.path; import javax.ws.rs.pathparam; import javax.ws.rs.produces; import sample.ims.data.*; /** * A sample resource that provides access to * server configuration properties */ @Path(value="/addresses") public class PhoneBookRS { public PhoneBookRS() { } private static String[] list = new String[] { "LAST1", "LAST2", "LAST3" }; @GET @Produces(value="text/plain") public String getlist() throws ResourceException { StringBuffer buffer = new StringBuffer(); buffer.append("{"); for (int i = 0; i < list.length; ++i) { System.out.println("i="+i+" Name1="+list[i]); if (i!= 0) { buffer.append(", "); buffer.append(" "); } INPUTMSG input = new INPUTMSG(); input.setin ll((short)59); input.setin zz((short)0); input.setin trcd("ivtno"); input.setin cmd("display1"); input.setin name1(list[i]); input.setin name2(""); input.setin extn(""); input.setin zip(""); PhoneBookImpl proxy = new PhoneBookImpl(); OUTPUTMSG output = proxy.getphonebook(input); System.out.println("\nName1:"+output.getOut name1()+"\n Name2:"+output.getOut name2()+" \nextension:"+output.getout extn()+" \nzip:"+output.getout zip()); buffer.append("\n Name1:"+output.getOut name1()+"\n Name2:"+output.getOut name2()+" \nextension:"+output.getout extn()+"\nzip:"+ output.getout zip()); } buffer.append("}"); } return buffer.tostring(); @GET @Produces(value="text/plain") @Path(value="{id}") public String getpropety(@pathparam("id") int id) throws ResourceException {

System.out.println("getProperty.id="+id); StringBuffer buffer = new StringBuffer(); if (id > -1 && id < list.length ) { INPUTMSG input = new INPUTMSG(); input.setin name1(list[id]); input.setin ll((short)59); input.setin zz((short)0); input.setin trcd("ivtno"); input.setin cmd("display1"); input.setin name2(""); input.setin extn(""); input.setin zip(""); PhoneBookImpl proxy = new PhoneBookImpl(); OUTPUTMSG output = proxy.getphonebook(input); buffer.append("\n Name1:"+output.getOut name1()+"\n Name2:"+output.getOut name2()+" \nextension:"+output.getout extn()+"\nzip:"+ output.getout zip()); return buffer.tostring(); } else { return "Customer Number Not Found"; } } @GET @Produces(value="text/html") @Path(value="html") public String gethtmllist() { return "<html><body><p><b>hello</b></body></html>"; } } Inspect Project Path Inspect the properties for the IMSWebRSProject In the Project Facets, you will see that JAX-RS (REST Web Services) is selected

In the Project References, ensure that the connector project and the EAR project is being selected.

Configure deployment descriptor web.xml 1. Open WebContent/WEB-INF/web.xml. In the Design view, select the Servlet JAX-RS Servlet and click Add and add an Initialization parameter to the JAX-RS servlet, Enter javax.ws.rs.application as param name and sample.ims.phone bookrsapplication as param value. Save the web.xml.

2. Right click on the EAR project and select Properties. Ensure that the Project References are referencing the connector project and the JAX-RS dynamic web project. 3. Now with everything configured and setup, we are ready to deploy and test the J2C JAX-RS web service. Right click the WebSphere Application Server and select Properties. Find out the HTTP port number, in this sample, it is 9080. The port number will be used when you invoke the J2C JAX-RS web service.

Test the JAX-RS Web service 1. In the Servers view, right-click your server and select Add and Remove Projects, and add the JAX-RS EAR to the server. Restart the server. 2. Open a Web browser and enter the following URL: http://localhost:<default_host_port>/ IMSWebRSProject/jaxrs/addresses/<address index> The address assigned to that index value will display. 3. To retrieve all addresses in the Address Book application, enter the following URL: http:// localhost:<default_host_port>/imswebrsproject/jaxrs/addresses

By specifying the second index to the list that contains an array of last name, it will return the second phone book record:

If you do not specify the index, all the phone book records will be displayed: