Une balade dans DOUAI par Michel Le 31.01.2013 En partant de la Place du Barlet départ.
Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf ·...
Transcript of Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf ·...
![Page 1: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/1.jpg)
© All rights reserved. Zend Technologies, Inc.
Mike Pavlak
Solutions Consultant
(815) 722 3454
Function Junction
Rest Web Service on IBM i
![Page 2: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/2.jpg)
© All rights reserved. Zend Technologies, Inc.
Agenda
• Discuss web services in general
• DB2 access
• Product Availability RPG Program
• Q&A
| 2 02/04/10
![Page 3: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/3.jpg)
© All rights reserved. Zend Technologies, Inc.
Housekeeping & safety
![Page 4: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/4.jpg)
© All rights reserved. Zend Technologies, Inc.
Update Zend Server for IBM i
Zend Server Download Page – IBM I tab…
Zend Server 5.6
Hotfix 7
Toolkit Update 12/12
![Page 5: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/5.jpg)
© All rights reserved. Zend Technologies, Inc.
What’s up with Web Services
![Page 6: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/6.jpg)
© All rights reserved. Zend Technologies, Inc.
Introduction to Web Services
• Tightly coupled
Mine, mine, mine…I own it all! mwa-ha-ha-ha-ha
API program calls
Stored procedures and ODBC
• Loosely coupled
We don’t own all of our business logic
Web Services
Mash-ups
![Page 7: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/7.jpg)
© All rights reserved. Zend Technologies, Inc.
Direct Program Call
Program A
Order Entry
Program B
Pricing
Advantages Compiled code Stable, predictable & efficient Changes required on both sides ensure security Disadvantages Changes require recompile Test, test, test Intersystem calls cumbersome
Product, Customer, Quantity returns Price
![Page 8: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/8.jpg)
© All rights reserved. Zend Technologies, Inc.
Usher in the new age of computing!
• Books that are the basis for my position
The Cathedral & the Bazaar by Eric Raymond
• Open Source is OK!
• Dynamic is in, Monolithic is out
• But there is room for both…for a while
Small Pieces Loosely Joined by David Weinberger
• Modular is better!
• Many small pieces around the Internet
• Scattered amongst the cloud!
| 8 Name of this section | Feb
![Page 9: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/9.jpg)
© All rights reserved. Zend Technologies, Inc.
What is a Web Service?
• W3C says...
A software system designed to support interoperable machine to machine interaction over a network.
• Key words
Software system
Interoperable
Machine to machine
Network
• It’s really just another way to call programs!
![Page 10: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/10.jpg)
© All rights reserved. Zend Technologies, Inc.
Who uses Web Services? • Web presence today
Google Maps, Spell checkers, etc.
Amazon.com Product availability, Order processing
Salesforce.com Application Integration
TerraServer Cloud based applications
Many, many more
• API layer replacement tomorrow
Inter-program communication
Inter-system communication
![Page 11: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/11.jpg)
© All rights reserved. Zend Technologies, Inc.
Why use Web Services? • SOA Layer
Fancy term for modern program calls!
Parts are self defining and self documenting
Code is modular from the start
Facilitate the upgrade process
| 11 Name of this section | Feb
Program A
Program B
Yesterday’s program call Today’s program call
Program A
Program B
Program call
![Page 12: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/12.jpg)
© All rights reserved. Zend Technologies, Inc.
What types
SOAP
Simple Object Access Protocol
Self defining
Can be highly complex
ReST
Representational State Transfer
Much like API call
Requires external documentation
![Page 13: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/13.jpg)
© All rights reserved. Zend Technologies, Inc.
Data Access using ReST
![Page 14: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/14.jpg)
© All rights reserved. Zend Technologies, Inc.
One example for two methods
Part 1
Form with drop down info populated by web service
Select product and then move to part two
No data on local IBM i
Part 2
Take selected item and call web service
Remote web service calls RPG program
RPG program develops on hand quantity & returns
Again, no data on local IBM i
![Page 15: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/15.jpg)
© All rights reserved. Zend Technologies, Inc.
Two system setup
Local & remote both IBM i for this example
Local system can be ANY platform running PHP
Remote system can also be any platform
In this example is IBM i
But must have access to Inventory data
Inventory availability is in RPG business logic
Simple example, can be VERY complex!
![Page 16: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/16.jpg)
© All rights reserved. Zend Technologies, Inc.
HTML Form using PHP
![Page 17: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/17.jpg)
© All rights reserved. Zend Technologies, Inc.
Form source
![Page 18: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/18.jpg)
© All rights reserved. Zend Technologies, Inc.
WSCommon.php
Common routines and standard locations
Here I store the location of my services
Easy to adjust and I can scan for common services
I’m using hardcoded IPs, but recommend DNS
![Page 19: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/19.jpg)
© All rights reserved. Zend Technologies, Inc.
Target LPAR and host service, part 1
![Page 20: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/20.jpg)
© All rights reserved. Zend Technologies, Inc.
Server Utils Part 1
![Page 21: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/21.jpg)
© All rights reserved. Zend Technologies, Inc.
Call RPG using ReST
![Page 22: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/22.jpg)
© All rights reserved. Zend Technologies, Inc.
Remote service calls RPG
Review
Created form to display products
Products available listed on remote system
Have product ID
Now look up remote system for availability
![Page 23: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/23.jpg)
© All rights reserved. Zend Technologies, Inc.
Select product from form
![Page 24: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/24.jpg)
© All rights reserved. Zend Technologies, Inc.
Form source
![Page 25: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/25.jpg)
© All rights reserved. Zend Technologies, Inc.
Now call WSClient2.php
![Page 26: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/26.jpg)
© All rights reserved. Zend Technologies, Inc.
Target LPAR and host service, part 2
![Page 27: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/27.jpg)
© All rights reserved. Zend Technologies, Inc.
RPG code
![Page 28: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/28.jpg)
© All rights reserved. Zend Technologies, Inc.
WSClient2.php receieves info and presents
![Page 29: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/29.jpg)
© All rights reserved. Zend Technologies, Inc.
Final output
Not pretty, but would be used in finished application
Shows on hand quantity for product selected
![Page 30: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/30.jpg)
© All rights reserved. Zend Technologies, Inc.
Feature article at iProDeveloper
With your subscription
Can read article and download code
![Page 31: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/31.jpg)
© All rights reserved. Zend Technologies, Inc.
Wrap it up!
![Page 32: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/32.jpg)
© All rights reserved. Zend Technologies, Inc.
Events where you’ll find Zend…
32 Insert->Header & Footer
COMMON.org - (Tampa Feb 12-13 & Austin Apr 7-10)
Systemideveloper.com - (Altlanta March 19-21)
![Page 33: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/33.jpg)
© All rights reserved. Zend Technologies, Inc.
Education special at Zend.com
Great Introduction to PHP
Smart way to jump start PHP training
Linux/Windows and IBM i
Offer expires Jan 20, 2013
Sign up early!
![Page 34: Rest Web Service on IBM i - Zendstatic.zend.com/topics/ReSTfulWebService-20130116.pdf · 31.01.2013 · Form with drop down info populated by web service Select product and then move](https://reader033.fdocuments.net/reader033/viewer/2022041422/5e1f9fd83198fc2ab50fb46b/html5/thumbnails/34.jpg)
© All rights reserved. Zend Technologies, Inc. 34 Insert->Header & Footer
Q&A
www.zend.com