Web Services - Where do I start?
Last Post 10 Jan 2013 09:03 AM by Ringer. 23 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Page 1 of 212 > >>
Author Messages
Commando850
New Member
New Member
Posts:14

--
02 Jan 2013 04:11 PM

Hello everyone.

I have been an RPG developer on the iSeries for may years. Recently our company has had a need to consume data via a Web Service from one of our 3rd party vendors. I would like to consume the Web Service from our iSeries as the data that I need to download needs to be input into our DB2 data base,

The Web Service used SOAP & SSL (https). I have managed to use IBM's WSDL2WS to create an Service Program on our iSeries. The Service Program is massive, and unfortunately; I don't know how to call the subprocedures in a way that will return data. The documentation on their web site for this Web Service is terrible, and in many cases wrong. Their customer service is non-existant if you don't know .NET.

I downloaded the trial version of soapUI (http://www.soapui.org/). With this trial version I have been able to create XML requests that successfully return data frm the Web Service in question. Whoopee...this is great!!! Now if I could just figure out how to do this from an RPG program.

I have also downloaded Scott Klement's HTTPAPI open source API. I have been able to get some of Scott's "examples" to work, however; there are a lot that I can't get to work. I'm not sure this API is a great starting point for a beginner such as myself. I have been trying to use it for quite some time but I still don't really have any idea what it is doing most of the time. I've read through a lot of the documentation as well, but I confess that I don't understand most of it. I've never been able to successfully receive data with it.  

I don't know Java, or C, or C++, or C# or .NET. I'm not a web programmer nor am computer communications expert. This being said, I am at a bit of a loss as to what courses I should take, and/or books I should read so I can get up to speed with this stuff. Has anyone else been in my situatiuon? Where do I start with my training?

Any help much appreciated. Paul 

 

Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
02 Jan 2013 04:53 PM

Paul,

How familiar are you with XML? I use XMLI - http://xmli.sourceforge.net/ to build the xml they have documentation on how to do it (as well as some examples). To retrieve the XML from the webservice in of itself is straightforward:

filename = http_tempfile() + '.xml';                   
rc = http_url_get(url : filename);                     
if (rc <> 1);                                          
  {error processing }                               
else;                                                  
  Options = 'doc=file path=root/data/struct case=any + 
     countPrefix=cnt';                                 
  xml-into retField %xml(filename : Options);          
  unlink(filename);                                    
ENDIF;                                                 

File name is a link generated by Scott's httpapi routine http_tempfile - it's purpose is to create a unique file in the '/tmp' directory. The routine http_url_get is the routine that retrieves the response from the 3rd party vendor - the url is the full url - including the xml - for the request for webservice. The response from the 3rd party vendor is stored in file represneted by filename.

The xml-into is a bit more intense - get the code to retrive the response back from the vendor first - I'll be happy to step you through the xml-into then - but first let's walk before we run. Don't implement the xml-into or the unlink as of yet.

Commando850
New Member
New Member
Posts:14

--
03 Jan 2013 09:44 AM

Thanks for your response Rocky.

Unfortunately I don't have a lot of XML experience.

I've downloaded the XMLi API and restored library XMLILIB on my iSeries. Unfortunately their BUILD program doesn't seem to work. This seems like a very complex API similar to HTTPAPI (not really for a beginner). I've read through some of the documentation and examples. I don't really understand how this API will help me build something to consume a Webservice? I know I have to create an XML Request to send to the Webservice, but the way it has to be built is dictated by the Webservice. How would XMLi know what our vendor wants in the XML Request??? Sorry...I don't get it.

I've used soapUI to build example XML Request that work...couldn't I just copy paste these into a field in the RPG???

I don't really understand your code. It looks to me as if your not passing anything subprocedure http_tempfile()...how would this subprocedure know what kind of XML to create?

Paul. 

JJ Dahlheimer
Advanced Member
Advanced Member
Posts:626

--
03 Jan 2013 09:58 AM
Did you go through Scott presentation on consuming web services. http://www.scottklement.com/present...TTPAPI.pdf

I knew very little of web services when I started with it and got through and just started modifying his code until I got what I wanted.
Commando850
New Member
New Member
Posts:14

--
03 Jan 2013 10:03 AM

Thanks JJ Dahlheimer.

I've actually tried to go through Scott's presentation on consuming web services several times, but I still don't get how to use it in the real world.

Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 10:05 AM

I'm curious about the BUILD not working - what version of IBM i are you running?

XMLi API is used to actually create the XML - you have to determine what tags are needed based on the documentation provided by the 3rd party vendor.

XML is similar to HTML insofar that it's based on tags - a beginnng tag and an ending tag for example:

product description

The name of the tag is Product - the value of Product is between the tages Product and /Product.

You can build this without using the API - you just have to create a CHAR variable that is large enough to contain the whole string and put the example XML into that variable - the XMLi API makes it easier to build it on the fly with variable data is all.

Once you create the XML into a CHAR field - append that to the URI of the 3rd party (for example, in my case a sample URI+XML would look something like:

https://demo.pointandpay.net/api3/?instream=###*********FeeCreditCard8593.16                                             

The above is what the variable url contains in my sample code (with actual username & password of course) - the webservice responds with XML that is put into the location represented by filename.

As an alternative - study the presentation - and the example code is EXAMPL16 in LIBHTTP.

JJ Dahlheimer
Advanced Member
Advanced Member
Posts:626

--
03 Jan 2013 10:18 AM
I am with Rocky, I think you are going to have to spend more time with the presentation and ask specific question about it if you get stuck as that is probably the best place to start.
Commando850
New Member
New Member
Posts:14

--
03 Jan 2013 11:00 AM

Thanks Guys.

We are running a Power7 Model: 8202/E4C Processor group: EPC6 O/S: V6R1

I have been over and over Scotts presentation. I've been working on this for literally months! It's very discouraging. I spent days trying to make the UPS example in that presentation work. I finally posted on Scotts forum and was told by Scott himself that this was a very old POX example that probably doesn't work anymore...and he's right....it doesn't.

I was able to get EXAMPLE16 to work, but I don't really understand it. It's not really what I need anyway. It doesn't use SSL or a UserID and Password. Any time I try to run any example that uses https I get error "ssl_error(406): (GSKit) I/O: Unknown system state (next line) SetError() #24: gsk_env_init: (GSKit) I/O: Unknown system state." Nobody...including Scott...seems to know what this error means...I have IBM looking at it right now.

The whole point of this thread was that, I'm trying to understand what I am missing - education/training wise - that makes this stuff so hard for me to understand. Is there no way that someone can be trained to understand this stuff...or does everyone else just pick it up on-the-fly? If there isn't any training I feel I may be doomed.  

 

 

 

Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 11:29 AM
Yeah - I hear ya - I went to a conference about a month and a half ago for the very reason to learn how to do this myself.

When you compiled the HTTPAPI of scott's - seems ot me it asked about SSL - was it compiled to support SSL?

If you GO LICPGM and take option 10 - do you have the Digital Certificat Manager and CCA Cryptoggraphic Service Provider? (5761SS1 - options 34 & 35)?
Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 11:38 AM
You will need:
5761-SS1 Digital Certificate Manager
5761-SS1 System Openness Includes (option 13).
5761-DG1 IBM HTTP server for i5/OS
5761-SS1 CCA Cryptographic Service Provider (Install says 57xx-ACx Cryptographic Access Provider - but I think this is the older nomenclature)
*** 57xx-CE3 IBM Client Encryption is now part of the OS

When you did the CALL INSTALL step it asks 2 questions - Would you like to build the sample programs? and Would you like to build HTTPAPI with SSL Support? You should've answered both with a 'Y'.
Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 11:46 AM
*** Trying to figure out how to delete a message....
Commando850
New Member
New Member
Posts:14

--
03 Jan 2013 12:17 PM
Hi Rocky. I just checked my box and we have the following.

Licensed       Installed
Program          Status             Description
5761SS1    *COMPATIBLE    Digital Certificate Manager
5761SS1    *COMPATIBLE    System Openness Includes
5761DG1    *COMPATIBLE    IBM HTTP Server for i5/OS
5761SS1    *COMPATIBLE    CCA Cryptographic Service Provider
5722CE2    *INSTALLED       Client Encryption 128-bit

I do remember that when I did the CALL INSTALL for HTTPAPI I answered “Y” to both building sample programs & SSL Support.
Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 01:29 PM
I went to IBM i Devcon to learn how to deal with XML and web services.... what vendor is it - more speicfically you have the link that gives the vendor documentation and go from there.
Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 01:34 PM
There is yet another possibility - http://www.rpg-xml.com - they have a product that you can use to do this very thing - and the best part is they have technical support to step you through the whole process.


Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
03 Jan 2013 02:03 PM
Posted By Commando850 on 03 Jan 2013 12:00 PM

I was able to get EXAMPLE16 to work, but I don't really understand it. It's not really what I need anyway. It doesn't use SSL or a UserID and Password. Any time I try to run any example that uses https I get error "ssl_error(406): (GSKit) I/O: Unknown system state (next line) SetError() #24: gsk_env_init: (GSKit) I/O: Unknown system state." Nobody...including Scott...seems to know what this error means...I have IBM looking at it right now.

 


The error message says "The GSK component is unable to validate the self-signed certificate"

The document dealing with this is located at http://www-01.ibm.com/support/docvi...wg21260562

 

Commando850
New Member
New Member
Posts:14

--
04 Jan 2013 07:12 AM

Thank Rocky...all of your help is much appreciated.

I will have a look at the document you sent - see if I can figure out what's going on with our Digital Certificate.

Wonder of wonders!!! Late last night I actually managed to get a program to work that uses HTTPAPI procedure http_url_post_xml. Accoring to what I am seeing in debug the post is going out fine and I think I am getting data back...no errors anyway...now I just have to figure out how to get the data. One small step...

Thanks again for all of your help.

Paul.

 

Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
04 Jan 2013 08:31 AM
Paul,

That routine uses pointers to two subprocedures - and you have to extract the data using those two routines. Study EXAMPLE14 to see how it's used.

Can you share a URL of the vendor detailing the requirements of the webservice?
Ringer
Veteran Member
Veteran Member
Posts:1758
Avatar

--
04 Jan 2013 08:53 AM
Paul,

If you turn the HTTP debug on before doing the POST, you can see the entire request to response in a text file on your IFS, which is very cool. You can name the debug file whatever you want.

D DebugFileName s 500a Varying

YourDebugFileName = '/tmp/whatever_debug_' + datetime + psds.JobNum + '.txt' ;
http_debug(*On : YourDebugFileName) ;
http_url_post_xml( ... ) ;

After program runs:
DSPF '/tmp/yourfilenamehere.txt'

Chris Ringer
Commando850
New Member
New Member
Posts:14

--
04 Jan 2013 02:21 PM
Thanks to both Rocky and Ringer for your responses.

I have been away from my desk most of the day.

IBM is still looking at the problem I'm having with an https post. GSKit I/O Unknown system state.

I love the http_debug with a file idea - I'll try this first thing on Monday.

I'll let you know how I made out with both.

In the meantime, have a great weekend.

Paul.
Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
07 Jan 2013 01:17 PM
Paul,

I got to playing around w/httapi and learned a few things - the way you started is easier than the way that I was going to show you... I figured it would be the other way around...

When you're ready, let me know... I'd be happy to help.

Rocky
You are not authorized to post a reply.
Page 1 of 212 > >>


Acceptable Use Policy