Solved

iSeries Webservices

Posted on 2010-11-18
17
1,307 Views
Last Modified: 2012-06-22
Hi experts,

Webservices....? totally new for me, so please give me some help (no link to red books).

The situasion is:
A Web application is sending a request to ??? (Somewhere)
that ends up in the iSeries (Somehow)
this must trigger an RPG program (Someway)
and return a data string (Something)

I found info about WebSphere Development Studio Client for iSeries
My questions:
How can I send something from the iSeries to somewhere
- Is there an API that i can use (example)?
- Do I need to use WDS (preferable not)
-- If Webspere Develoment Studio is used, do I need to run a Websphere Server ?

The input from the web is probably XML
and the output also I think.

Please give me a point to start with, because this is one big gray area for me :(

Thanks,
Murphey
0
Comment
Question by:theo kouwenhoven
  • 9
  • 5
  • 3
17 Comments
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34165262
Murph,

Web services are just that: API's that are exposed via an HTTP interfaces (usually).  Think RPC.  If you've ever written a data queue driven program, then you've done something similar.  A data queue driven program watches a data queue for a new entry.  WHen the entry arrives, it does some processing, and perhaps returns a result on a different queue (or through some alternate mechanism).

A web service waits for a message to be received (usually via HTTP) on a TCP port that it monitors, performs some processing, and then returns a resulting message back the same way.  Multiple different functions can be published over a single web service.  The messages are usually formatted in XML, and the entire interface (list of functions, message formats for each function) are usually described using XML-based WSDL (Web Services Description Language).  

WSDL example: http://www.tutorialspoint.com/wsdl/wsdl_example.htm

You can develop a web service any way you want:

As a native application written in RPG, COBOL, or C/C++.
An AS/400 Java application with or without Websphere
A non-AS/400 application (Java or .NET, perhaps) that accesses the AS/400 via ODBC/JDBC/ADO/FTP/Client Access API/DDM/FTP/etc.

IBM's method is to use WAS, and to generate a Java "web service wrapper" for your RPG/COBOL program.  They've created tools that make this pretty easy to do, provided you are running WAS and use WDSC.

Here is a tutorial that is not a Redbook:

http://www-01.ibm.com/support/docview.wss?rs=3239&context=SSZND2&uid=swg27009770

Here's a good article that explains how to CONSUME a web service from RPG or COBOL on the AS/400 (the opposite of what you want to do, you want to PUBLISH a web service, it sounds like):

http://www.ibm.com/developerworks/systems/library/es-webservicesrpg/

Scott Klement has a handout and code samples that show how to publish a web service

Of course, there is a great Redbook on the subject that is designed to teach a beginner like you what you need to know to implement a Web Service.  Please don't look at the link below - it is not for you, it is just for anyone else that might find this question and is interested in actually seeing the best reference for the job.

:-)

*** Not for Murph****
http://www-01.ibm.com/support/docview.wss?rs=3239&context=SSZND2&uid=swg27009770
***Not for Murph ****

- Gary Patterson


0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34165284
Pasted the wrong link for the Redbook!  

Again - not for Murph:

http://www.redbooks.ibm.com/redpapers/pdfs/redp0192.pdf

- Gary Patterson
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 34166696
LOL :-)

Yes nice all that books and links have you any idea haw many pages I read today?

Just give me a very very very simple explanation what will happen if the user hit his enter key on the webapp.
until he see the result, what is active and where.

and.....
How do I write a webservice in RPG? without java and other non-professional languages :-) :-)
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 34166889
What I like to know is:

What part is running where (using an RPG to process the request ofcourse),
and what part is doiing what..

Whatever document I take, they all point to WDSC or ununderstandable lines like:

You can use a simple JNI native call, or you can use Program Call Markup Language (PCML) through the
IBM Toolbox for Java.
 -or-
a Java Bean that interfaces directly with a native iSeries program.
 -or-
By using a socket server

I'm a very simple RPGxx programmer not willing to give a part of this process to a PC/java "professional",
so I go for 100% iSeries (RPG) supported solution.

0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34167577
Well, most of the world doesn't create web services entirely in RPG, so you're going to find a limited number of references by comparison to other methods, like Java or .Net, and you're going to have to do a lot more research into HOW a web service works than if you just use WDSC to generate a web service wrapper for a RPG program for you.

There are lots of ways to create a web service.  Some easier than others.  Java=Very easy.  RPG=Pretty hard.

That's why you should start with that Redbook that I'm not allowed to mention, and just read it.  It is less than 80 pages.  Then you'll know what PCML is, plus WSDL, SOAP, and a bunch of other acronyms and initialisms used when dealing with web services.

It explains what a web service is, how it works, and how to create one using WDSC on the AS/400.  Until you understand what a web service is, you probably won't have much luck creating one.

In a typical AS/400 Websphere environment, the web service consists of a Java front-end program that runs in an application server (WAS, for example), and calls the native RPG (for example) program when invoked with a properly-formatted request.  

I've also seen PHP-based solutions that do the same basic thing, minus the need for an AS like Websphere.

The web service program handles the details of waiting for incoming connections, creating a maintaining a socket connection with the client, all the details of HTTP-protocol conversations with the client, parsing and creating XML, parameter passing to and from the native program, etc.

The nice thing about using Java for this is that WDSC will automate most of this process for you.

If you want to do it in RPG, then you'll have to handle all of the communications coding yourself.  If you plan to do that, you might find Scott Klement's open source (native) HTTPAPI code useful:

http://www.scottklement.com/httpapi/

Because publishing a web service is a bit more complicated than consuming one, most of the RPG examples out there are for consumers, but they will at least give you an idea from the client perspective what is involved.  Plus you'll need a consumer in order to test your publisher.

http://systeminetwork.com/article/rpg-web-service-consumer

- Gary Patterson
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34167841
The term "web service" is a little confusing, since it can be used in a generic sense (any application that is accessible via HTTP), or in a specific sense:  HTTP/SOAP/WSDL/XML.  I'm using the second sense.

Just give me a very very very simple explanation what will happen if the user hit his enter key on the webapp.
until he see the result, what is active and where.


That's easy.  Nothing.  A web service isn't an interactive application.  It is a PROGRAM-TO-PROGRAM service.  For example, you might create a web service to allow a customer's APPLICATION to interface to your system to retrieve order status information.

A user at one of your company's clients opens up their in-house intranet web page, and selects a link that says "Check Status of an Order at MurphyCo".
They enter an order number on the web page created by their in-house web developer, and click "Get Order Status"
Their web application establishes a socket connection across the internet to your web service, which is running in Websphere on your AS/400.
Their application formats and sends a properly-formatted XML request to your web service using the HTTP protocol.  Their programmer knew how to format this request because she had the WDSL document that described the interface, including the list of functions that were available, and the types of input and output parameters (messages in web services-speak).
Your web service receives the "input" messages, parses the parameters out of the XML, and calls your RPG Order Status program.
Your RPG Order Status program does its thing, and returns "Shipped" to the Java web service program.
The Java web service program formats the response into a proper XML response (as described in the WSDL), and handles the details of returning the message via HTTP to the customer's client program.
The customer's program formats a web page for the user that says "That order is in SHIPPED status."

How do I write a webservice in RPG? without java and other non-professional languages :-) :-)

I don't have an RPG example of a web service, and I have no plans to write one.  I've given you some links to articles that show how to write client programs that consume a web service, but I can't find one that shows an RPG example of publishing a web service.  Most people don't go down this path once they figure out how much easier it is to create web services using other tools.

You can use a simple JNI native call, or you can use Program Call Markup Language (PCML) through the IBM Toolbox for Java.
 -or-
a Java Bean that interfaces directly with a native iSeries program.
 -or-
By using a socket server


These comments are not talking directly about creating a web service - just about the process of calling a native (RPG/COBOL/etc) program from a Java program.  If your web service needs to call a native program, then you need a way to do that, and pass parameters (usually) to and from the JAVA and RPG programs.  These are three methods that you can use in a Java program to call a native program.  But simply calling a native program from Java doesn't make it a web service, at lest not by most definitions.

- Gary Patterson



0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34167980
Here's a training class for just what you want to do, that includes source code, apparently.  I've never take the class.  Look at the table of contents, though, and you'll get an idea of how much learning curve you are looking at:

http://www.rpg-xml.com/xmlwebservices.aspx

There is also a V6R1 feature (available by PTF in V5R4) called Integrated Web Services (IWS) that is apparently designed to simplify creation of web services from native programs.  I haven't used this yet, so I can't offer much insight, but if I was starting where you are, and WAS is definitely out of the picture, then I'd take some time and look into IWS:

http://www.itjungle.com/fhg/fhg120909-story02.html
 
- Gary Patterson
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 34168393
SO I understand, I need WAS or IWS to get it up and running, my program talks to that with a "normal" parameter and WAS or IWS is the part that translate it from and to XML?
Hmm maks it a little more understandable.... so I will start to install WSDC....

Thanks a lot !!!!

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34168668
You don't "need" WAS or IWS, but either greatly simplifies the task versus implementing everything you need in RPG.  IWS looks like an interesting option.

Maybe another expert has used it and can comment.

- Gary Patterson
0
 
LVL 5

Expert Comment

by:stevebowdoin
ID: 34169244
Murph

You are where I was a few months ago.

I had to implement Verizon’s Field Force Manager.  This is a web service.

I used Scott Klement's code.  He is part of an open source project.  Scott is the driving force but many others are vital to that cause.  One of them is in Germany.  When I can find his web site I will send it to you.

You should start with Scott’s web page: http://www.scottklement.com/oss.html

Here are some of the basic steps.
1      get the WSDL from the service provider.  This is a file that describes the data.  Not meant for human consumption.

2      feed the WSDL to one of the programs you will get from Scott.
3      that program will create a sample RPG program.
4      modify that program to do your work.

Man, did I shorten that trip!!

What’s going to happen when you are done is that your program will send a stream of data to the web service in the form it is expecting.  Then it will respond with a web page that your program will read.  Your program will receive arrays of data.  You loop thru the array and get your data.

It’s not as bad as you would think.

I did the whole thing with out writing and C or Java.  All my work in RPG.

Steve Bowdoin
0
 
LVL 16

Author Comment

by:theo kouwenhoven
ID: 34169762

Hi Steve,

feed the WSDL to one of the programs you will get from Scott.
  that program will create a sample RPG program.

Sounds great, what tool is that?
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34169822
Sounds like a nice shortcut to developing it from scratch!

- Gary Patterson
0
 
LVL 5

Expert Comment

by:stevebowdoin
ID: 34173092
Murph.

Here is a link: http://www.tools400.de/English/Freeware/WSDL2RPG/wsdl2rpg.html

WSDL2RPG is the program that will create the sample RPG program from the WSDL.

You will need Scott Klement's HTTPAPI.

This is far from doing it from scratch.  Gary, have you tried it?

Steve
0
 
LVL 34

Expert Comment

by:Gary Patterson
ID: 34173303
I've used WSDL2RPG to generate code for a simple web service consumer, but not a publisher.  

I used Scott's HTTPAPI and FTPAPI for several tasks: was very handy for an app that needed to scrape data from a web page without resorting to Java.  

That said, I'm a Java programmer and a Microsoft VB / and .NET programmer as well as an RPG programmer, so it doesn't bother me to use the tool that is best for the job.  Sometimes that is Java.

Didn't realize WSDL2RPG was useful in building Web Service publishers - thought it was just for consumers.  How to you use it to build publisher when you don't have a WSDL to start with - that's usually part of the publisher development process?

- Gary Patterson
0
 
LVL 5

Expert Comment

by:stevebowdoin
ID: 34175673
Murph’s question did not state whether he is a consumer or a publisher.  I assumed he would be consuming.  I may be wrong.

Help us out Murph.  Are you reading someone else's data or are you producing it for others.  UPS and others publish web services for package tracking.  Users of that would be consumers.

I have done a grand total of one web service project.  I don't conceder myself an expert.
Once I found these tools I described, I finished the project in two days.

Gary, if I don’t become a Java programmer, it may be difficult to make a living.   I learn a great deal from your posts.  Thanks.

Steve Bowdoin
 
0
 
LVL 34

Accepted Solution

by:
Gary Patterson earned 250 total points
ID: 34176218
Steve,

I read Murph's post as describing a web service publisher.  I just think he (sticking with the masculine pronoun unless Murph corrects me) is new enough to web services that he doesn't know the terminology.  

Here's what led me to this conclusion:

The situasion is:
A Web application is sending a request to ??? (Somewhere)
that ends up in the iSeries (Somehow)
this must trigger an RPG program (Someway)
and return a data string (Something)


Request comes in, and an AS/400 program needs to be called to provide a response.  That's a publisher.

My questions:
How can I send something from the iSeries to somewhere


Sending information outbound is publishing.  Requesting info is consuming.

The input from the web is probably XML
and the output also I think.


Refers to "input from the web" = Request / Consumer
Output (from the AS/400, clearly) = Response/Publisher

Anyway, if we're talking about building a consumer, then I think we're done.  You've identified the tool.  I think we're talking about a publisher, though.

BTW: I'm not a web services expert by any means, but I've done a bit (AS/400 RPG consumer, Java publisher talking to AS/400 native programs, straight Java publisher, Java consumers updating client AS/400 database, .NET consumers and publishers with and without AS/400 interfaces), and helped with a piece here or there with others.

I'm not as adept at Java and .NET as I am with RPG, but I was a DOS and Unix programmer for a short time before I was an AS/400 RPG programmer, and I've kept up with PC development tools and languages throughout my career.  Mostly in cross-platform applications that touch the AS/400 somehow, but enough to keep my hand in.  

I learned Java, on the other hand, just in order to help Don Denoncourt at Midrange Computing with teaching overflow from a very popular Java for AS/400 Programmers seminar that he taught.  I was teaching their ILE RPG seminars and private classes and some of their AS/400 Operations seminars at the time, and was looking to pick up more work from MC.  I was not a Java convert at the time, but since then I've come to appreciate the value, especially with so much free software to do complex tasks freely available in Java.  I often turn to Java on the AS/400 now for Excel parsing and generating, PDF generation, XML parsing and generation, email, FTP, stream file handling, almost anything communications-related, web services, dynamic web page generation with JSP, image manipulation, complex string handing, and the like.  

Nice to be able to do it on the AS/400 instead of handing it off to a PC server like we used to do.

I work as a consultant full-time, and I have come to specialize in cross-platform development, troubleshooting, plus cross-platform performance analysis and remediation (and whatever I else I can get paid to do!).  As a result, I get to get my hands into a lot of different tools, technologies, and platforms.  My company is a Microsoft, Cisco, and IBM partner (among others) and I deal with support issues for all three, which helps to keep it all fresh, too: it is a small company and we all wear lots of hats.

I've certainly benefited from your posts here, too - you always have something interesting to contribute.  I'm glad you brought up WSDL2RPG and HTTPAPI - good tools, and certainly related to the question no matter what.

- Gary Patterson
0
 
LVL 16

Author Closing Comment

by:theo kouwenhoven
ID: 34177697
Aha I'm a consumer and a publisher... now I understand a lot more about this documents I have her .... :-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

When coding a Webservice to provide data, the normal way is to create a method that returns a Dataset object.   But a Dataset cannot be used easily from another platform, such as PHP,  FLAS (FLEX) , etc. Solution : Return a XML Document instea…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now