29
Fri, Nov
0 New Articles

Web Services for the Traditional RPG Programmer, Part I

Development Tools
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

There is no doubt about it: The world of the traditional AS/400, iSeries, System i5 programmer is changing. The world of the Web has descended upon us or maybe even passed us by (was that the strange whizzing noise I heard?). Numerous new technologies and products (along with a corresponding host of new acronyms) appear to be requirements for providing information to and receiving information from different interfaces. We no longer live in a green-screen world.

The Web is the one interface that stands out above all of the others. And the Web has progressed beyond simply providing static or dynamic Web pages for human interaction: Web services are the means by which applications can communicate with each other over the Web, with no human intervention required.

The difficulties facing the traditional programmer in this brave new world usually fall into one of two categories: Either learn the new technologies or learn to communicate with the new employees who are implementing them. The latter is probably the harder of the two, since both parties end up trying to find common ground while using completely different terminology. Do you ever find yourself reading an article on WebSphere or Java and giving up halfway through because you don't understand most of the terms being used? I refuse to admit how often it happens to me.

I think we can be forgiven for feeling slightly left behind. In this article, I will present an overview of Web services from the perspective of the traditional programmer, and, in a follow-on article, I will provide an example of using WebSphere Development Studio Client (WDSC) to generate a Web service for an existing RPG subprocedure. This will provide an introduction to some of the concepts of Web services and demonstrate how a traditional programmer can generate a Web service to call a subprocedure or a program without having to become an expert in the 50 flavors of Web services.

What Is a Web Service?

At the risk of over-simplifying, a Web service is a transaction service that runs over the Web. This means that you need to use some form of application server, such as WebSphere, Tomcat, or JBoss. Many third-party applications also provide Web services, or you could even have a go at writing your own.

A Web service is provided through a URL: The Web service is invoked when the URL is requested.

A client codes a request as an eXtensible Markup Language (XML) message and invokes the service. The service processes the request, generates an XML message as a response, and returns it to the client.

Could this be why those new XML operation codes and built-in functions were introduced in the V5R4 release of RPG IV?

What Is the Problem?

What exactly is the problem that Web services are trying to solve? Primarily, it is one of integration. The nature of the Web is that you have multiple hardware platforms, operating systems, and programming languages all trying to communicate with each other in a meaningful way. This is not just a simple issue of presenting information on Web pages; instead, it's a means of making information available and accessing information through a Web-enabled interface.

For example, your customers have a requirement to access order-status information. You have made this information easily available to them on a Web page, but they want a means of incorporating the information directly into their own applications—and it is not acceptable to tell them to copy and paste. A Web service provides a means whereby your customers' application programs can request the order information via the Web and have the information returned in a "standard" format that they can process easily.

Or you might have a requirement to perform credit validation when you create a new customer account. Wouldn't be nice to be able to do this directly from an RPG program?

Get the Back-End Right

Before you even start contemplating Web services, you must give a lot of consideration to the state of your application. Let me present you with a fairly common scenario. A company has a traditional green-screen application that has been serving the business requirements for 15 years. But the business requirements are changing, and there is now a need for access from the Web and for information to be provided from multiple sources, not just the traditional phone and fax. The company knows that the existing application has all the complex business logic required, so, quite sensibly, it wants to utilize what it already has. Where does the company start? The mistake made by most companies is that they start at the front-end. They spend a lot of time deciding what the front-end should look like, what the middle tools should be, and whether it should use CGI, .NET, WebSphere, or another of the multitude of products available. And when all that is ready, the company suddenly realizes that the traditional application is very much geared toward working with a green-screen and consists of monolithic programs that don't fit the model of working with the new application interface.

So the first step is to get the back-end right. This means that you must truly modularize the application and separate the database process from the business logic from the interface. This in turn means you must fully utilize the benefits of RPG IV and ILE. When this is done, you are ready to have any sort of interface use your application. This really is one of the key elements of applications that use Web services. You must take the approach that, in the back-end application, not one line of code will change when the company suddenly decides that the technology it chose was the wrong one and it's going to switch (e.g., from .NET to WebSphere/Java or vice versa).

From the traditional programmer's point of view, it would do no harm to gain some understanding of how the Web works and how to program for it. I think the best place to start is with CGIDEV2, a free development tool that enables you to write RPG programs that will output to and input from Web pages. Basically, CGIDEV2 is a service program containing procedures that make it very easy to use the CGI APIs. Learning to use CGIDEV2 will show you how to interface with the Web and provide some understanding of the problems solved by application servers, JavaServer Pages (JSPs), and Java servlets. You can go to the Easy400 site for all your CGIDEV2 requirements.

In a lot of cases, CGIDEV2 may well satisfy your business needs for presenting and receiving data, but the design principle remains the same, and you must separate the interface from the business logic.

Once you have your application (or parts of your application) in a well-modularized state, you're ready to start experimenting with the wonders of Web services.

Why Use Web Services?

At first glance, Web services would appear to be just the latest flavor of transaction services. You could be forgiven for having that feeling of déjà vu by just replacing the term "Web services" with Remote Procedure Call (RPC), Electronic Data Interchange (EDI), Remote Database Access, or Remote Messaging.

But Web services provide a few advantages over the more traditional forms of transaction services:

  • Web services have an open standard architecture for linking different applications types on different servers.
  • There is a low cost of implementation because you can use existing Web infrastructures. Communication is via the Web as opposed to some form of direct communication.
  • Web services do not require proprietary tools, software, or code. Server and client applications can be written in different languages and run on different platforms.
  • There is an ever-increasing level of support from vendors in tooling and runtime environments.
  • Web services registries are being implemented by industry to enable integration between customers and suppliers.
  • But most importantly, assuming you have modularized your application, the same code provides information to all clients as opposed to using different application programs, depending on who issues the request.

But implementing Web services also has potential disadvantages:

  • If you are already implementing one of the traditional transaction services, is there any business benefit to be gained from implementing Web services?
  • If you do not have an existing Web infrastructure, you will need to implement one. This can be quite an undertaking and may require expertise and skills that are not currently available in your company.
  • Performance may be an issue because you are dependent on the performance of your Web access.
  • Security is also a consideration because information is passed via the Web as opposed to some form of "direct" communication.
  • Your application is not in a state to be used by a Web service. I know I am starting to sound like a broken record, but this is still the biggest stumbling block for implementing Web services. You must restructure your back-end applications into callable modular structures.

Regardless of the pros and cons, you can be assured that Web services are here to stay. They are becoming a standard (and a requirement in some industries) and are being implemented in an ever-growing number of applications.

Terms and Conditions

The use of a Web service requires compliance to standards, and it is important to be aware of some of the methods (and terms) used to implement these standards.

  • XML is a specification developed by the World Wide Web Consortium (W3C) for defining mark-up languages (much like HTML). It enables the definition, validation, and interpretation of data between applications. Requests to and responses from a Web service are messages in an XML format.
  • Web Services Description Language (WDSL) is used to describe an interface to Web Services (what the Web service can do, how to invoke it, what the structure of the parameters is, which communications protocols to use).
  • Simple Object Access Protocol (SOAP) is an XML-based protocol used to encode request and response messages before sending them over the network. These SOAP messages must match the message formats defined in the WSDL document.

How Does a Web Service Work?

At its simplest level (the best place to start), a Web service is a straightforward process very much like requesting information from an HTTP server:

  1. A client application creates a request as an XML message using a SOAP framework and invokes a Web service via a URL on a server.
  2. The server interprets the request from the XML message and processes it by calling the relevant program or procedure.
  3. The server creates a response as an XML message using the SOAP framework and sends it back to the client. The response message will contain either the requested information (if the request was successful) or an error (if it failed).
  4. The client receives the XML message and processes it to access the response data.

The process is not that complicated. But for most of us, the only piece of the process that we fully comprehend is the "relevant program or procedure" that is called by the Web service. This is the good old RPG program or subprocedure that has always done our bidding. The generation of a Web service requires the generation of a "wrapper" program that will decipher an XML request, call our program or procedure, interpret values returned, and put them in an XML format.

The good news is that you can use WDSC (which you should already be using for your day-to-day programming requirements) to generate and test a Web service request without having to gain any knowledge of application servers, XML, JSPs, or Java. You can then safely pass it all on to your Web application server gurus.

Got It?

Hopefully, you now have an understanding of what Web services are and of some of the components required to make them work.

In my next article, I will demonstrate how to generate and test a Web service using WDSC to do all the hard work.

Paul Tuohy has worked in the development of IBM midrange applications since the '70s. He has been IT manager for Kodak Ireland Ltd. and Technical Director of Precision Software Ltd. and is currently CEO of ComCon, a midrange consultancy company based in Dublin, Ireland. He has been teaching and lecturing since the mid-’80s.

Paul writes articles for many publications and is one of the quoted industry experts in the IBM Redbook Who Knew You Could Do That with RPG IV? He is the author of the books The Programmer's Guide to iSeries Navigator and Re-engineering RPG Legacy Applications as well as the self-teach course “iSeries Navigator for Programmers.”

He is also an award winning speaker who speaks regularly at COMMON conferences, the renowned RPG and DB2 Summit, and other conferences throughout the world.

 

Paul Tuohy

Paul Tuohy has worked in the development of IBM midrange applications since the 1970s. He has been IT manager for Kodak Ireland, Ltd., and technical director of Precision Software, Ltd., and is currently CEO of ComCon, a midrange consultancy company based in Dublin, Ireland. He has been teaching and lecturing since the mid-1980s. 

Paul is the author of Re-engineering RPG Legacy Applications, The Programmer's Guide to iSeries Navigator, and the self-teach course "iSeries Navigator for Programmers." He is one of the partners of System i Developer and, in addition to speaking at the renowned RPG & DB2 Summit, he is an award-winning speaker at COMMON and other conferences throughout the world.


MC Press books written by Paul Tuohy available now on the MC Press Bookstore.

The Programmer’s Guide to iSeries Navigator The Programmer’s Guide to iSeries Navigator
Get to know iSeries Navigator and all the powerful tools and interfaces that will expand your programming horizons.
List Price $74.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: