1
Web services and IBM i
Introduction to
Web services for RPG developers
Claus Weiss clausweiss22@gmail.com
TUG meeting March 2011
TUG Seneca night school program
2
Web services and IBM i
Acknowledgement
In parts of this presentation I am using work published b!
"inda #ole$ IBM #anada
Scott %lement$ %lement Sausage #o&$ Inc&
TUG Seneca night school program
3
Web services and IBM i
Agenda
Using RPG
Using %G&
With %G&
2ne application that calls a remote network is tied strongl to it b the function call it makes and the parameters
it re3uests
4i5ed interface to access remote programs or data$ with little fle5ibilit or adaptabilit to changing environments
or needs
What are Web services!
:ardware platforms
2perating sstems
)rogramming languages
TUG Seneca night school program
6
Web services and IBM i
Tpes of web services
Allowing to easil access the web service via the internet or intranet
Where is it located
Web Service
S2A)
WS("
U((I Universal (escription$ (iscover and Integration
U66I did not become accepted as the standard registr" for Web
ervices
TUG Seneca night school program
14
Web services and IBM i
U((I overview
#hart created b U((I 2ASIS Standard communit
TUG Seneca night school program
15
Web services and IBM i
Wh use a Web Service
?ahoo for business information 7show me realtors for that postal code8
&&&&
Using RPG
Using %G&
With %G&
"ike a function,subprocedure
In the (eploment (escriptor ou tell the generator what kind of service to create
for the logic ou code in the Service part
teps teps
Use the Web ervice 'i8ard to test the service Use the Web ervice 'i8ard to test the service
TUG Seneca night school program
27
Web services and IBM i
%G& program 8ipervice
$er(i'e ZipSer(i'e
fun'tion zipSer(i'efun'tion6zipin
$trin1 in7 zipout $trin1 out8
if 6zipin >= 9900019 :: zipin = 99!00098"
zipout = 909"
e#$e
zipout = 9=%19"
end
end
end
:ow it Works H #reating a Web Service with <G"
#reate program,service
#reate service dialog
Zip'ode in
Return (a#ue
0 or %1
TUG Seneca night school program
28
Web services and IBM i
)SD*
De$'ri+e$ $er(i'e
,nd $er(i'e
interfa'e$
<G" service IipService
:ow it Works H #reating a Web Service with <G"
#reate the Web Service
)e+ Ser(i'e
;a(a $er(#et
),R or E,R
Generate
Zip'ode in
Return (a#ue
0 or %1
%G& Web ervice generation
$reate 9M& for service
$reate <ava servlet
$reate Web application W*R/%*R file
6eplo" to Tomcat or W*
$reate W6&
TUG Seneca night school program
29
Web services and IBM i
)SD*
De$'ri+e$ $er(i'e
,nd $er(i'e
interfa'e$
:ow it Works H #reating a Web Service with <G"
Test Web Service
*pp erver
)e+ Ser(i'e
),R -it. Ser(#et
Web Service <5plorer
'ead W(S"
#reate front end
to send re3uest
with data
(ispla response
Re3ue$t
-it. 45*
do'u2ent
'ontainin1
Zip'ode in
Re$pon$e -it. Return
(a#ue
TUG Seneca night school program
30
Web services and IBM i
'un the <G" Web Service
Input to service
2utput from service
Web Service
TUG Seneca night school program
31
Web services and IBM i
#reating a Web Service
Using RPG
Using %G&
With %G&
teps
$ompile
Tr"
TUG Seneca night school program
37
Web services and IBM i
')G consuming Web Service using >ava generated b <G"
ILE business logic
rotot!pes to call
"ava
%G& logic
D* this is the constructor for the !"/#$%$ program &rapper
D ne&'&rap (R ) *T(R)+,*#$%$ - .programs.(rogramc/
D 01rapper. - *+)23TR4+T)R5
D*
D* call method for &rapper program ob6ect
D* 7 input parameters8 response &ill be in third parameter
D callmeth (R 9t(roc,*#$%$-
D .programs.(rogramc01rapper.-
D .call.5
D parm: 7;i ; <alue
D parm7 ) +lass,*#$%$-.6a<a.math.=igDecimal.5
D parm0 ) +lass,*#$%$-.6a<a.lang.3tring.5
Wrapper program
ProgramcBWrapper
2 input parms
1 response parm
Generated <ava program
sends reCuest to Web
ervice and gets
response
TUG Seneca night school program
38
Web services and IBM i
')G consuming Web Service using >ava generated b <G"
ILE business logic
call to "ava
wrapper
%G& logic
D mypgm: s o class,*#$%$-
D .programs.(rogramc01rapper.5
D response s >;a <arying
mypgm: = ne&'&rap,5?
// send re@uest to &eb ser<ice
callmeth,mypgm:- parm:- parm7 -parm05?
// response from 1eb 3er<ice is stored in parm0
// method getmyparm0 gets the response <alue
response = getbytes, getmyparm0,mypgm:55?
Wrapper program
ProgramcBWrapper
2 input parms
1 response parm
Generated <ava program
sends reCuest to Web
ervice and gets response
*pp erver
)e+ Ser(i'e
),R -it.
Ser(#et
TUG Seneca night school program
39
Web services and IBM i
Steps for consuming a Web Service using :TT)A)I
teps
$ompile
Tr"
TUG Seneca night school program
40
Web services and IBM i
Use soapUI to e5tract 9M" document
$reate a pro:ect in soapUI