Your SlideShare is downloading. ×
Session: Practical Web Services for RPG  http://www.ibm.com/systems/i/software/iws/                    Page 1 of 60
Agenda  .....................................................................................................................
Lab Information     Lab Prerequisites          To get the most out of this lab you should be familiar with RPG and Web dev...
Objectives     The example application you will be working with during the Integrated Web Services lab     exercises is ba...
Fictional Case Study – Over the Top Coffee"Over the Top Coffee" is a local coffee store in the city of Seattle who focuses...
Practical Web Services for RPGThe integrated web services server and the integrated web services client for ILE enables IL...
IBM Integrated Web Services for i – Server LabLab ExercisesExercise 1: Review the example Coffee Bean Inventory Applicatio...
o2. With a 5250 session, examine the RPG source code used to generate the Coffee Bean Inventoryapplication’s RPG business ...
Exercise 2: Create an IBM Integrated Web Services Server for iObjective: In this exercise you will create an IBM integrate...
o4. The Create Web Services Server wizard is displayed.   oa. Step 1 of 3: Read the displayed panel and then select Next. ...
oc. Step 3 of 3: A summary of the Create Web Services Server wizard is displayed.    od. Click on the Servers tab and writ...
og. While you are waiting for the Create Web Services Server wizard to complete you’ll notice     the status in the upper ...
Exercise 3: Review Starting/Stopping an Integrated Web Services ServerObjective: In this exercise, you will review startin...
Exercise 4: Review the IBM Integrated Web Services Server for iObjective: In these exercises you will review properties of...
ob. Click on the Ports tab and review what information is shown.oc. Click on the Web Services Server tab and review what i...
o2. Stop your web services server <WSERVICEyy>.         oa. Click the red stop button in the upper left hand corner of the...
o4. Start your web services server <WSERVICEyy>.           oa. Click the green start button in the upper left hand corner ...
Exercise 4b: Manage Deployed Services   o1. With your <WSERVICEyy> server selected in the Server drop-down list, click “Ma...
ob. Examine the properties for the ConvertTemp web service by reviewing the informationshown on the General tab.    oc. Cl...
COBOL) on other platforms to interact with the native business logic found in your IBM i      ILE Programs and Service Pro...
Exercise 4c: Example 1 - Test the ConvertTemp Web Service   An example web service called ConvertTemp is deployed with all...
ob. The IBM Web Service Test Client for i will be invoked. Displayed on the left is the   WSDL Navigator panel, on the rig...
ob. Click Add next to input parameter _TEMPIN and specify a value of 32 in the input field,then click the Go button.      ...
oc. The converttemp operation’s return parameter data will be displayed in the Status panel at       the bottom of the IBM...
ob. The Status panel will display the SOAP message details for the request and response SOAPenvelopes. The request SOAP en...
o5. In the Navigator panel, click the converttemp_XML operation.       ob. After clicking the converttemp_XML operation, t...
ob. Click Add next to input parameter _TEMPIN and specify a value of 32 in the input field,then click the Go button.   oc....
o4. You can review the converttemp operation’s response in more detail by viewing the Source link.The Source link displays...
Exercise 4d: View the SOAP Message Tracing Logs   o1. With your <WSERVICEyy> web services server selected in the Server dr...
o2. Page down in the list of Application Server Logs for server <WSERVICEyy> and click on             /www/<WSERVICEyy>/lw...
Exercise 5: Deploy RPG Business Logic as a Web ServiceIntroduction: "Over the Top Coffee" is a local coffee store in the c...
Exercise 5a: The CoffeeBeanInventory Web ServiceThis exercise will go through the steps required to successfully deploy th...
ob. Step 2 of 9: Enter the following values to reference the RPG business logic (ILE serviceprogram) for the CoffeeBeanInv...
od. Step 4 of 9: Select Expand All and set the following Usage and Count fields as indicated,then select Next.   Note: By ...
of. Step 6 of 9: Take the default values for the library list entries and select Next.og. Step 7 of 9: Take the default va...
oh. Step 8 of 9: Take the default values for WSDL options and select Next.oi. Step 9 of 9: Review the final summary panel ...
oj. When the Deploy New Service Wizard completes, click on the “Manage Deployed Services”link and verify the newly deploye...
Exercise 5b: The WarehouseCoffeeBeanInventory Web ServiceThis exercise will go through the steps required to successfully ...
ob. Step 2 of 9: Enter the following values to reference the RPG business logic (ILE serviceprogram) for the WarehouseCoff...
od. Step 4 of 9: Select Expand All and set the following Usage fields as indicated, then selectNext.   oe. Step 5 of 9: Ta...
of. Step 6 of 9: Take the default values for the library list entries and select Next.og. Step 7 of 9: Take the default va...
oi. Step 9 of 9: Review the final summary panel and select Finish.       Note: The Deploy New Service wizard will go off a...
oj. When the Deploy New Service Wizard completes, click on the “Manage Deployed Services”   link and verify the newly depl...
Exercise 6: Test Deployed Web Services on IBM iObjective: In these exercises you will test the CoffeeBeanInventory web ser...
ob. The IBM Web Service Test Client for i will be invoked. Displayed on the left is theWSDL Navigator panel, on the right ...
Exercise 6a: Test Operation getitemsObjective: In this exercise you will test the getitems operation found in web service ...
Exercise 6b: Test Operation additemObjective: In this exercise you will test the additem operation found in web service Co...
ob. In the Actions panel, click on the Go button to invoke the additem operation. Theoperation’s return parameter data wil...
Exercise 6c: Test Operation changeitemObjective: In this exercise you will test the changeitem operation found in web serv...
ob. In the Actions panel, click on the Go button to invoke the changeitem operation. Theoperation’s return parameter data ...
Exercise 6d: Test Operation removeitemObjective: In this exercise you will test the removeitem operation found in web serv...
ob. In the Actions panel, click on the Go button to invoke the removeitem operation. The     operation’s return parameter ...
Exercise 7: Consume the “WarehouseCoffeeBeanInventory” Web Servicefrom an RPG ClientIntroduction: The Over the Top Coffee ...
Exercise 7a: Generate and Review Client Stub CodeBefore you can create a web service client application, you must first ge...
o2. Let us examine what is generated by the wsdl2ws.sh tool Issue the following commands withinQShell:      oa. cd /INVENT...
od. Examine the WarehouseCoffeeBeanInventoryPortType.rpgleinc file by issuing the followingCL command:   edtf /INVENTRYxx/...
Exercise 7b: Review Client Source Code and Create Application  o1. With a 5250 session, review the RPG source code for the...
o2. With a 5250 session, compile the RPG source code for the RPG client application that consumesthe WarehouseCoffeeBeanIn...
Exercise 7c: Consume the WarehouseCoffeeBeanInventory Web Service    o1. With a 5250 session, view Over the Top Coffee’s c...
o3. Now call Over the Top Coffee’s in-house 5250 “Green Screen” Coffee Bean Inventory Applicationagain to see if each coff...
Upcoming SlideShare
Loading in...5
×

Practical web services for RPG lab exercises

2,893

Published on

COMMON Europe Congress 2012 - Vienna

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,893
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
56
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Practical web services for RPG lab exercises"

  1. 1. Session: Practical Web Services for RPG http://www.ibm.com/systems/i/software/iws/ Page 1 of 60
  2. 2. Agenda ...........................................................................................................................................................................................................1.............................................................................................................................................................................................................1AGENDA.............................................................................................................................................................................................2 LAB INFORMATION...............................................................................................................................................................................3 Lab Prerequisites.......................................................................................................................................................................3 Software and Tool Requirements...............................................................................................................................................3 Lab Setup....................................................................................................................................................................................3 Objectives...................................................................................................................................................................................4 Notes...........................................................................................................................................................................................4 Where to Find More Information...............................................................................................................................................4FICTIONAL CASE STUDY – OVER THE TOP COFFEE..........................................................................................................5PRACTICAL WEB SERVICES FOR RPG....................................................................................................................................6LAB EXERCISES .............................................................................................................................................................................7 EXERCISE 1: REVIEW THE EXAMPLE COFFEE BEAN INVENTORY APPLICATION...............................................................................................7 EXERCISE 2: CREATE AN IBM INTEGRATED WEB SERVICES SERVER FOR I..................................................................................................9 EXERCISE 3: REVIEW STARTING/STOPPING AN INTEGRATED WEB SERVICES SERVER...................................................................................13 EXERCISE 4: REVIEW THE IBM INTEGRATED WEB SERVICES SERVER FOR I..............................................................................................14 Exercise 4a: Server Properties................................................................................................................................................14 Exercise 4b: Manage Deployed Services................................................................................................................................18 Exercise 4c: Example 1 - Test the ConvertTemp Web Service................................................................................................21 Exercise 4d: View the SOAP Message Tracing Logs..............................................................................................................29 EXERCISE 5: DEPLOY RPG BUSINESS LOGIC AS A WEB SERVICE............................................................................................................31 Exercise 5a: The CoffeeBeanInventory Web Service..............................................................................................................32 Exercise 5b: The WarehouseCoffeeBeanInventory Web Service............................................................................................38 EXERCISE 6: TEST DEPLOYED WEB SERVICES ON IBM I........................................................................................................................44 Exercise 6a: Test Operation getitems......................................................................................................................................46 Exercise 6b: Test Operation additem......................................................................................................................................47 Exercise 6c: Test Operation changeitem.................................................................................................................................49 Exercise 6d: Test Operation removeitem................................................................................................................................51 EXERCISE 7: CONSUME THE “WAREHOUSECOFFEEBEANINVENTORY” WEB SERVICE FROM AN RPG CLIENT................................................53 Exercise 7a: Generate and Review Client Stub Code............................................................................................................54 Exercise 7b: Review Client Source Code and Create Application..........................................................................................57 Exercise 7c: Consume the WarehouseCoffeeBeanInventory Web Service..............................................................................59 Page 2 of 60
  3. 3. Lab Information Lab Prerequisites To get the most out of this lab you should be familiar with RPG and Web development concepts. Experience with the IBM Web administration for i GUI could also be helpful, but it isn’t necessary. This is a self-guided lab to gain hands-on experience working with the Integrated Web Services Server available with IBM i starting in release 5.4. Software and Tool Requirements • IBM Personal Communications Software must be installed on the lab computers. • Web browser (Firefox or IE) must be installed on the lab computers. • IBM i server running 6.1 (or above) with prerequisites installed. Prerequisites documented at: http://www.ibm.com/systems/i/software/iws/support.html . Lab Setup The following preparatory steps have been completed for you: • All the necessary software prerequisites and tools are installed on the lab computers and server. • The necessary lab user profiles, user libraries, files, and programs have been created on the lab server. Lab user profiles have been authorized to the appropriate objects. These are the steps you should perform before completing any of the lab exercises: o1. Bring up an IBM i 5250 terminal session by double-clicking on the icon on your PC desktop. Ensure you bring up the correct system used for this lab. o2. Sign on using your assigned lab userid and password. During the lab you will be instructed when to use IBM i commands. o3. Bring up a Web browser by double-clicking on the Firefox or Internet Explorer icon on your PC desktop. This Web browser will be used for working with the IBM integrated web services server for i. Page 3 of 60
  4. 4. Objectives The example application you will be working with during the Integrated Web Services lab exercises is based on a fictional case study about a coffee store called “Over the Top Coffee. Please read the section in this lab titled “Fictional Case Study – Over the Top Coffee” for some background information about this fictional coffee store. This lab has the following objectives: • Review the Over the Top Coffee store’s in-house coffee inventory application • Create an IBM integrated web services server for i • Review the IBM integrated web services server for i • Deploy RPG business logic as a web service • Test deployed web services using the IBM i Web Services Test ClientNotes • Please do NOT change or edit anything on the lab server other than what you are instructed to do during the lab. • Throughout the lab, when you see INVENTRYxx, you should replace xx with your assigned team number.Where to Find More Information http://www.ibm.com/systems/i/software/iws/ Page 4 of 60
  5. 5. Fictional Case Study – Over the Top Coffee"Over the Top Coffee" is a local coffee store in the city of Seattle who focuses on delivering the best andmost premium coffee beans at a fair price. Their Coffee Inventory application was written in RPG and iscurrently a "Green Screen" 5250 application which was architected 10 years ago. It is an excellentapplication, efficient, well tuned, and perfect for Over the Top Coffee’s in-house inventory needs.The Over the Top Coffee store has recently received word from their “green (unroasted) coffee beans”supplier that they’ve upgraded their Warehouse Coffee Ordering application so it is now directly accessibleto their clients via a new coffee ordering web service. Over the Top Coffee would like to automate theircoffee supply ordering process by writing a RPG client program (to run nightly) that will run a checkagainst the store’s local coffee inventory and automatically order more coffee from their supplier’swarehouse (via the new “WarehouseCoffeeBeanInventory” web service). More coffee will be orderedwhenever the combined sum of each coffee product’s in stock inventory count and its on order inventorycount is less than 25 items. Page 5 of 60
  6. 6. Practical Web Services for RPGThe integrated web services server and the integrated web services client for ILE enables ILE applicationsto play in the web services and SOA arena with very little effort, knowledge and resources. Theconvergence of web services and IBM i technologies can help enterprises liberate these core business assetsby making it easier to enrich, modernize, extend and reuse them well beyond their original scope of design.Many businesses are seeing benefits in moving their information technology (IT) infrastructure to makegreater use of standards as they roll out new applications and services, and to better exploit their existinginfrastructure. In doing this, businesses have recognized that they need to become more flexible, allowingthem to address new business opportunities more quickly by reusing more of their existing assets, includingcurrently running business processes and applications.By choosing to move to a Service Oriented Architecture (SOA), businesses can ensure that they design andbuild their IT infrastructure using an architectural style that supports service orientation. By linking togetheryour business as a set of connected services, your IT infrastructure will be more flexible and responsive,allowing your business to be more flexible and responsive in turn.The question for businesses is how to get there? Companies are hampered by the very technologies they relyon to run their businesses. Many of their core information IT applications written in integrated languageenvironment (ILE) languages such as RPG and COBOL have been in service for years — even decades.Developed and optimized over a period of years, these applications are difficult to link to new technologiessuch as web services and SOA — until now.Getting started with web services and SOA on IBM i is easier than ever with the Integrate web servicesserver for IBM i. The bottom line is that flexible businesses require flexible IT, and the path to flexible IT isweb services and SOA.Integrated Web Services for IBM ihttp://www.ibm.com/systems/i/software/iws/ Page 6 of 60
  7. 7. IBM Integrated Web Services for i – Server LabLab ExercisesExercise 1: Review the example Coffee Bean Inventory ApplicationIntroduction: "Over the Top Coffee" is a local coffee store in the city of Seattle who focuses on deliveringthe best and most premium coffee beans at a fair price. Their Coffee Inventory application was written inRPG and is currently a "Green Screen" 5250 application which was architected 10 years ago. It is anexcellent application, efficient, well tuned, and perfect for Over the Top Coffee’s in-house inventory needs.Objective: In this exercise you will review the “Green Screen” view of Over the Top Coffee’s in-housecoffee bean inventory application, along with some of the source code behind its internal RPG businesslogic. o1. With a 5250 session, run the example Coffee Bean Inventory Application by issuing the followingcommands from a command line: a. ADDLIBLE LIB(INVENTRYxx) b. CALL PGM(COFFEE) Note: You can add, change, or remove Coffee Bean inventory items from this displayed screen. Press F3 or F12 to exit the example Coffee Bean Inventory application’s display screen. Page 7 of 60
  8. 8. o2. With a 5250 session, examine the RPG source code used to generate the Coffee Bean Inventoryapplication’s RPG business logic. This business logic is self contained in an IBM i service program andwill later be deployed on an IBM integrated web services server for i (Exercise 3). oa. Issue STRPDM, Option 3. Specify file QRPGLESRC, library INVENTRYxx where xx is your assigned student number), and member name ITEM*. Press Enter. ob. The following file members will be displayed. View the files using Option 5=Display and F3=Exit. i. Member ITEMPR is the prototype definitions for the externalized Coffee Bean Inventory business logic procedure interfaces. ii. Member ITEM is the RPG procedure interfaces for the prototype definitions defined in member ITEMPR. Note: PCML information needs to exist to deploy an ILE program or service program on the IBM Integrated web services server for i. When you examine the ITEM RPG source code, you will notice Program Call Markup Language (PCML) information was specified to be included in the compiled RPG module via the following RPG Header specification (H- specs). h NOMAIN PGMINFO(*PCML:*MODULE) oc. Using this H-spec is the easiest way to ensure the proper PCML information is available. The PCML information can also be generated manually using an editor.** END OF EXERCISE 1 ** Page 8 of 60
  9. 9. Exercise 2: Create an IBM Integrated Web Services Server for iObjective: In this exercise you will create an IBM integrated web services server for i to use throughoutthe rest of these lab exercises. o1. With a browser, open the IBM Web Administration for i GUI. http://<hostname>:2001/HTTPAdmin o2. You will first have to enter your assigned team user id and password and press OK, before the IBMWeb Administration for i GUI will be shown. o3. On the IBM Web Administration for i console, you should be viewing the Manage ApplicationServers page. If not, here is how to get there: click on the Manage Tab then click on the ApplicationServers sub-tab. o4. Click on the Create Web Services Server link. Page 9 of 60
  10. 10. o4. The Create Web Services Server wizard is displayed. oa. Step 1 of 3: Read the displayed panel and then select Next. ob. Step 2 of 3: Read the displayed panel and then select Next. Page 10 of 60
  11. 11. oc. Step 3 of 3: A summary of the Create Web Services Server wizard is displayed. od. Click on the Servers tab and write down the server name, server root, server port (hint:the server URL contains the web services port number), and context root. Record the aboveinformation in the Team Information handout. You will use this information throughout therest of these lab exercises. oe. Click on the Services tab to see the URL for the ConvertTemp example web service thatthe Create Web Services Server wizard automatically deploys on each new web services serverinstance that is created. of. Click Finish so that the new web services server can be created. Page 11 of 60
  12. 12. og. While you are waiting for the Create Web Services Server wizard to complete you’ll notice the status in the upper left hand corner of the IBM Web Administration for i GUI has a status of “Creating”. Eventually the status will change to “Running”, however it might take a few moments before it does. Note: The name of your new web services server should be displayed in the Server drop- down list.** END OF EXERCISE 2 ** Page 12 of 60
  13. 13. Exercise 3: Review Starting/Stopping an Integrated Web Services ServerObjective: In this exercise, you will review starting/stopping an integrated web services server<WSERVICEyy>. o1. From the IBM Web Administration for i GUI, you should be viewing the Manage ApplicationServers page with your web services server <WSERVICEyy> selected in the Server drop-down list. If not,here is how to get there: Click on the Manage Tab, click on the Application Servers sub-tab, then selectyour web services server <WSERVICEyy> from the Server drop-down list. o2. If the status of your web services server <WSERVICEyy> says “Stopped”, click on green starticon to start your web services server and then click on the Start button. Then confirm your selection: o3. If the status of your web services server <WSERVICEyy> says “Creating” or “Starting”, click onthe blue restart button to refresh the status of your web services server. o4. If the status of your web services server <WSERVICEyy> says “Running”, no further action isnecessary to start your web services server. Note: The red stop button is also shown below. This buttoncan be used to manually stop a web services server.** END OF EXERCISE 3 ** Page 13 of 60
  14. 14. Exercise 4: Review the IBM Integrated Web Services Server for iObjective: In these exercises you will review properties of your IBM i web services server instance. oFrom the IBM Web Administration for i GUI, you should be viewing the Manage Application Serverspage with your web services server <WSERVICEyy> selected in the Server drop-down list. If not, here ishow to get there: Click on the Manage Tab, click on the Application Servers sub-tab, then select yourweb services server <WSERVICEyy> from the Server drop-down list.Exercise 4a: Server Properties o1. Select “Server Properties” on the left side of the browser display to expand the Server Propertieslinks, then click on the Properties link. oa. Review the information displayed under the Application Server tab. This tab shows information pertaining to your <WSERVICEyy> web services server instance. Page 14 of 60
  15. 15. ob. Click on the Ports tab and review what information is shown.oc. Click on the Web Services Server tab and review what information is shown. Note: This is the screen you would use to change a web services server’s context root. The default value is /web, however this property can be changed as long as the web services server is stopped. If the web services server is running, than the context root field is grayed out and un-editable. In addition, this panel allows you indicate what web service protocols are allowed to be used and various information relating to the WSDL file associated with the web service.od. Click the OK button. Page 15 of 60
  16. 16. o2. Stop your web services server <WSERVICEyy>. oa. Click the red stop button in the upper left hand corner of the IBM Web Administration for i GUI. Then confirm your selection: ob. Wait for the status of your web services server <WSERVICEyy> to go from “Running” to “Stopped” status. o3. Under the Server Properties link on the left side of the browser display, click on the ServerTracing link. oa. Click on the Web Services tab and review what information is shown. Change the Message tracing value from Disabled to Enabled and then click the Apply button. Note: The Message Tracing output will be reviewed in an exercise later on in this lab. Page 16 of 60
  17. 17. o4. Start your web services server <WSERVICEyy>. oa. Click the green start button in the upper left hand corner of the IBM Web Administration for i GUI. Then confirm your selection: ob. Wait for the status of your web services server <WSERVICEyy> to go from “Stopped” to “Running” status. You might have to hit the blue refresh button a few times until the status changes to Running. o5. Under the Server Properties link on the left side of the browser display, click on the View HTTPServers link. o a. Review the View HTTP Server information on the right side of the browser display. Page 17 of 60
  18. 18. Exercise 4b: Manage Deployed Services o1. With your <WSERVICEyy> server selected in the Server drop-down list, click “ManageDeployed Services” on either the left or center of the browser display. o2. The Manage Deployed Services panel is displayed. An example web service called ConvertTempis deployed with all new IBM integrated web services server for i instances. oa. Select the radio button next to the ConvertTemp service and click on the Properties button. Page 18 of 60
  19. 19. ob. Examine the properties for the ConvertTemp web service by reviewing the informationshown on the General tab. oc. Click on the rest of the tabs and examine the displayed properties. The Operations tab liststhe web service operations for the service and whether they are Enabled (thus can be invoked) orDisabled (and thus cannot be invoked). The Library List tab lists the libraries that will be added tothe library list when the web service implementation code is invoked. The WSDL tab allows you toregenerate the WSDL file associated with the web service and also modify it. The Connection Pooltab lists the properties associated with the pool of jobs associated with the web service. Finally, theRequest Information tab allows you to specify what transport information should be passed to theweb service implementation code. Prior to invoking the web service implementation code, anyselected transport information will be added to the job as environment variables. od. After reviewing all property tabs, click the OK button. oe Review the Web Services Description Language (WSDL) file for the ConvertTemp webservice by clicking on the “View definition” link. Note: The Web Services Description Language (WSDL) is a XML-based language that provides a model for describing web services. Although WSDL files look confusing, they indicate where a web service resides, what input parameters it accepts, and what output parameters it returns. They also allow programming languages (JAVA, .NET, C, C++, RPG, Page 19 of 60
  20. 20. COBOL) on other platforms to interact with the native business logic found in your IBM i ILE Programs and Service Programs. of. After reviewing the ConvertTemp WSDL file, close the window or tab opened when youclicked the “View definition” link. Page 20 of 60
  21. 21. Exercise 4c: Example 1 - Test the ConvertTemp Web Service An example web service called ConvertTemp is deployed with all new IBM i Web Service Server instances. This service converts temperatures in Fahrenheit to temperatures in Celsius and can be used as a test to verify whether or not a new web services server is working successfully. Follow the below steps to test your new web services server <WSERVICEyy> using the ConvertTemp web service. o1. With your <WSERVICEyy> web services server selected in the Server drop-down list, click“Manage Deployed Services” on either the left or center of the browser display. o2. The “Manage Deployed Services” panel will be displayed. Invoke the built-in IBM i WebServices Test Client using the following steps: oa. Select the radio button next to the ConvertTemp web service and click on the Test Service button. Page 21 of 60
  22. 22. ob. The IBM Web Service Test Client for i will be invoked. Displayed on the left is the WSDL Navigator panel, on the right is the Actions panel, and along the bottom you will find the Status panel.o3. In the Actions panel, click the converttemp operation. oa. After clicking the converttemp operation, the Actions panel is updated with information allowing the coverttemp operation to be invoked. Click Add to next to input parameter param0. Page 22 of 60
  23. 23. ob. Click Add next to input parameter _TEMPIN and specify a value of 32 in the input field,then click the Go button. Page 23 of 60
  24. 24. oc. The converttemp operation’s return parameter data will be displayed in the Status panel at the bottom of the IBM i Web Services Test Client browser display. Note: The return value in the Status panel has a value of 0, which is correct because 32 degrees Fahrenheit is 0 degrees Celsius. o4. You can review the converttemp operation’s response in more detail by viewing the Source link.The Source link displays the Request and Response SOAP message details and can be a very useful tool forproblem determination. oa. Make the Status panel larger by dragging the top line of the Status panel up toward the Actions panel using your mouse. Then click on the Source link on the far right of the Status panel. Page 24 of 60
  25. 25. ob. The Status panel will display the SOAP message details for the request and response SOAPenvelopes. The request SOAP envelope was sent to the ConvertTemp web service by the IBM WebService Test Client for i. The response SOAP envelope was returned from the ConvertTemp webservice. oc. You can stop showing the SOAP envelopes in the Status panel by clicking on the Form linkon the far right of the Status panel. od. You can exit the IBM Web Service Test Client for i by closing the browser tab that containsthe IBM Web Service Test Client for i window. Page 25 of 60
  26. 26. o5. In the Navigator panel, click the converttemp_XML operation. ob. After clicking the converttemp_XML operation, the Actions panel is updated with information allowing the coverttemp_XML operation to be invoked. Click Add to next to input parameter param0. Page 26 of 60
  27. 27. ob. Click Add next to input parameter _TEMPIN and specify a value of 32 in the input field,then click the Go button. oc. The converttemp_XML operation’s return parameter data will be displayed in the Statuspanel at the bottom of the IBM i Web Services Test Client browser display. Since you called theconverttemp_XML operation instead of the converttemp operation, the response is given in XMLformat. Note: The return value in the Status panel has a value of 0, which is correct because 32 degrees Fahrenheit is 0 degrees Celsius. Page 27 of 60
  28. 28. o4. You can review the converttemp operation’s response in more detail by viewing the Source link.The Source link displays the Request and Response SOAP message details and can be a very useful tool forproblem determination. oa. Make the Status panel larger by dragging the top line of the Status panel up toward the Actions panel using your mouse. Then click on the Source link on the far right of the Status panel. Page 28 of 60
  29. 29. Exercise 4d: View the SOAP Message Tracing Logs o1. With your <WSERVICEyy> web services server selected in the Server drop-down list, click“View Logs” in the lower left corner of the browser display. Page 29 of 60
  30. 30. o2. Page down in the list of Application Server Logs for server <WSERVICEyy> and click on /www/<WSERVICEyy>/lwi/logs/lwistdout.txt log file. o3. You should see SOAP message details from your previous tests of the ConvertTemp web service.Both the incoming message and the outgoing message should be in the log file.** END OF EXERCISE 4 ** Page 30 of 60
  31. 31. Exercise 5: Deploy RPG Business Logic as a Web ServiceIntroduction: "Over the Top Coffee" is a local coffee store in the city of Seattle who focuses on deliveringthe best and most premium coffee beans at a fair price. Their Coffee Bean Inventory application was writtenin RPG and is currently a "Green Screen" 5250 application which was architected 10 years ago. It is anexcellent application, efficient, well tuned, and perfect for Over the Top Coffee’s in-house inventory needs.Objective: In these exercises you will deploy the following RPG Business Logic as web services: Exercise 5a: Over the Top Coffee’s coffee bean inventory procedures. We will call this the “CoffeeBeanInventory” web service. Exercise 5b: Over the Top Coffee’s supplier’s new Warehouse Coffee Ordering web service. We will call this the “WarehouseCoffeeBeanInventory” web service. Note: Exercise 5b would normally be the supplier’s responsibility and the web service would run on one of the supplier’s servers, however in this lab we are going to use this web service as another example of how to deploy RPG business logic. Page 31 of 60
  32. 32. Exercise 5a: The CoffeeBeanInventory Web ServiceThis exercise will go through the steps required to successfully deploy the CoffeeBeanInventory webservice. The CoffeeBeanInventory web service will provide database access procedures that work withOver the Top Coffee’s Coffee Bean Inventory application. The externalized RPG database access logic thatwill be deployed is self contained in a ILE Service Program called ITEM. o1. With your <WSERVICEyy> web services server selected in the drop down field of the IBM WebAdministration for i GUI, select “Manage Deployed Services” on either the left or center of the browserdisplay. o2. The Manage Deployed Services panel is displayed. Click on the Deploy button to begin theDeploy New Service Wizard. oa. Step 1 of 9: Read the first panel and then select Next. Page 32 of 60
  33. 33. ob. Step 2 of 9: Enter the following values to reference the RPG business logic (ILE serviceprogram) for the CoffeeBeanInventory web service, then select Next. oc. Step 3 of 9: Enter the following values or accept the default values and then select Next. Page 33 of 60
  34. 34. od. Step 4 of 9: Select Expand All and set the following Usage and Count fields as indicated,then select Next. Note: By setting the Count field for parameter INVENTORY on procedure GetItems() to a value of RTNCOUNT (instead of the default value of 100) there is a slight performance gain. The performance gain is a result of the web service only having to return an array in parameter INVENTORY that is the exact size needed, as opposed to, having to return an array of 100 elements which has all of the unneeded array elements set to default values. oe. Step 5 of 9: Take the default value “Use server’s user ID” and select Next. Page 34 of 60
  35. 35. of. Step 6 of 9: Take the default values for the library list entries and select Next.og. Step 7 of 9: Take the default values for transport information to be passed and select Next. Page 35 of 60
  36. 36. oh. Step 8 of 9: Take the default values for WSDL options and select Next.oi. Step 9 of 9: Review the final summary panel and select Finish. Note: The Deploy New Service wizard will go off and generate the necessary Web artifacts and finish building the newly deployed web service. Page 36 of 60
  37. 37. oj. When the Deploy New Service Wizard completes, click on the “Manage Deployed Services”link and verify the newly deployed web service is in “Running” status. You may need to select theRefresh button a few times, if the wizard is still busy creating the new web service in the background. Page 37 of 60
  38. 38. Exercise 5b: The WarehouseCoffeeBeanInventory Web ServiceThis exercise will go through the steps required to successfully deploy the WarehouseCoffeeBeanInventoryweb service. The WarehouseCoffeeBeanInventory web service will provide a procedure to order moresupplies from Over the Top Coffee’s main supplier. The RPG business logic that will be deployed is selfcontained in a ILE Service Program called ORDERF. o1. With your <WSERVICEyy> web services server selected in the drop down field of the IBM WebAdministration for i GUI, select “Manage Deployed Services” on either the left or center of the browserdisplay. o2. The Manage Deployed Services panel is displayed. Click on the Deploy button to begin theDeploy New Service Wizard. oa. Step 1 of 9: Read the first panel and then select Next. Page 38 of 60
  39. 39. ob. Step 2 of 9: Enter the following values to reference the RPG business logic (ILE serviceprogram) for the WarehouseCoffeeBeanInventory web service, then select Next. oc. Step 3 of 9: Enter the following values or accept the default values and then select Next. Page 39 of 60
  40. 40. od. Step 4 of 9: Select Expand All and set the following Usage fields as indicated, then selectNext. oe. Step 5 of 9: Take the default value “Use server’s user ID” and select Next. Page 40 of 60
  41. 41. of. Step 6 of 9: Take the default values for the library list entries and select Next.og. Step 7 of 9: Take the default values for the transport information to be passed and select Next.oh. Step 8 of 9: Take the default values for WSDL options and select Next. Page 41 of 60
  42. 42. oi. Step 9 of 9: Review the final summary panel and select Finish. Note: The Deploy New Service wizard will go off and generate the necessary Web artifacts and finish building the newly deployed web service. Page 42 of 60
  43. 43. oj. When the Deploy New Service Wizard completes, click on the “Manage Deployed Services” link and verify the newly deployed web service is in “Running” status. You may need to select the Refresh button a few times, if the wizard is still busy creating the new web service in the background. o3. Click the WarehouseCoffeeBeanInventory service’s View definition link and record this service’sURL path in the Team Information handout. You will need this URL path when you implement the RPGclient program to consume Over the Top Coffee’s supplier’s ordering inventory web service calledWarehouseCoffeeBeanInventory in exercise 7. The WarehouseCoffeeBeanInventory service’s URL pathshould be of the following form: http://<hostname>:<port>/web/services/WarehouseCoffeeBeanInventory?wsdl** END OF EXERCISE 5 ** Page 43 of 60
  44. 44. Exercise 6: Test Deployed Web Services on IBM iObjective: In these exercises you will test the CoffeeBeanInventory web service operations that weredeployed in exercise 5a. o1. With your <WSERVICEyy> web services server selected in the drop down field of the IBM WebAdministration for i GUI, select “Manage Deployed Services” on either the left or center of the browserdisplay. o2. The “Manage Deployed Services” panel will be displayed. Invoke the built-in IBM i WebServices Test Client using the following steps: oa. Select the radio button next to the CoffeeBeanInventory web service and click on the Test Service button. Page 44 of 60
  45. 45. ob. The IBM Web Service Test Client for i will be invoked. Displayed on the left is theWSDL Navigator panel, on the right is the Actions panel, and along the bottom you will find theStatus panel. Page 45 of 60
  46. 46. Exercise 6a: Test Operation getitemsObjective: In this exercise you will test the getitems operation found in web service CoffeeBeanInventory. o1. In the Actions panel, click the getitems operation. oa. After clicking the getitems operation, the Actions panel is updated with information allowing the getitems operation to be invoked. Click the Go button. The getitems operation’s return parameter data will be displayed in the Status panel at the bottom of the IBM i Web Services Test Client browser display. Note: The INVENTORY parameter in the Status panel can be expanded in order to view the return parameter data. The RTNCOUNT parameter contains how many items were returned by the getitems operation. Page 46 of 60
  47. 47. Exercise 6b: Test Operation additemObjective: In this exercise you will test the additem operation found in web service CoffeeBeanInventory. o1. In the Actions panel, click the additem operation. oa. After clicking the additem operation, the Actions panel is updated with information allowing the additem operation to be invoked. Fill in the following values. Page 47 of 60
  48. 48. ob. In the Actions panel, click on the Go button to invoke the additem operation. Theoperation’s return parameter data will be displayed in the Status panel at the bottom of the IBM iWeb Services Test Client browser display. Note: A return value of 1 means the operation was successful. A return value of 0 means the operation was unsuccessful. Page 48 of 60
  49. 49. Exercise 6c: Test Operation changeitemObjective: In this exercise you will test the changeitem operation found in web serviceCoffeeBeanInventory. o1. In the Actions panel, click the changeitem operation. oa. After clicking the changeitem operation, the Actions panel is updated with information allowing the changeitem operation to be invoked. Update the input parameters as follows: Page 49 of 60
  50. 50. ob. In the Actions panel, click on the Go button to invoke the changeitem operation. Theoperation’s return parameter data will be displayed in the Status panel at the bottom of the IBM iWeb Services Test Client browser display. Note: A return value of 1 means the operation was successful. A return value of 0 means the operation was unsuccessful. Page 50 of 60
  51. 51. Exercise 6d: Test Operation removeitemObjective: In this exercise you will test the removeitem operation found in web serviceCoffeeBeanInventory. o1. In the Actions panel, click the removeitem operation. oa. After clicking the removeitem operation, the Actions panel is updated with information allowing the removeitem operation to be invoked. Update the input parameters as follows: Page 51 of 60
  52. 52. ob. In the Actions panel, click on the Go button to invoke the removeitem operation. The operation’s return parameter data will be displayed in the Status panel at the bottom of the IBM i Web Services Test Client browser display. Note: A return value of 1 means the operation was successful. A return value of 0 means the operation was unsuccessful.** END OF EXERCISE 6 ** Page 52 of 60
  53. 53. Exercise 7: Consume the “WarehouseCoffeeBeanInventory” Web Servicefrom an RPG ClientIntroduction: The Over the Top Coffee store has recently received word from their “green (unroasted)coffee beans” supplier that they’ve upgraded their Warehouse Coffee Ordering application so it is nowdirectly accessible to their clients via a new coffee ordering web service. Over the Top Coffee would like toautomate their coffee supply ordering process by writing a RPG client program (to run nightly) that will runa check against the store’s local coffee inventory and automatically order more coffee from their supplier’swarehouse (via the new “WarehouseCoffeeBeanInventory” web service). More coffee will be orderedwhenever the combined sum of each coffee product’s in stock inventory count and its on order inventorycount is less than 25 items.Objective: In these exercises you will create the RPG client program (responsible for ordering morecoffee) that will consume the “WarehouseCoffeeBeanInventory” web service you deployed (Exercise 5b). Exercise 7a: Generate RPG stub code and create service program containing stub code. Exercise 7b: Create the RPG application that uses the stub code to consume web service. Page 53 of 60
  54. 54. Exercise 7a: Generate and Review Client Stub CodeBefore you can create a web service client application, you must first generate the client stubs using thewsdl2ws.sh tool. The wsdl2ws.sh tool uses the WSDL file that is passed to create the client stubs. We willbe using the WSDL file for the WarehouseCoffeeBeanInventory web service. To generate the client stubsfrom your WSDL source file, complete the following steps. o1. Generate the client stub code responsible for communicating with theWarehouseCoffeeBeanInventory web service. oa. Ensure your web services server is in a running state. ob. Start a QSHELL session by issuing the QSH CL command from an IBM i command line and pressing Enter. oc. Run the below wsdl2ws.sh tool from QSHELL to generate the client stubs by typing in the following command and pressing Enter: /QIBM/ProdData/OS/WebServices/V1/client/bin/wsdl2ws.sh -lrpg -o/INVENTRYxx –s/qsys.lib/INVENTRYxx.lib/WCBISTUB.srvpgm http://<hostname>:<port>/web/services/WarehouseCoffeeBeanInventory?wsdl Note: Replace INVENTRYxx with your team’s directory. In addition, replace the host name and port in the WSDL URI with your server’s host and port. The URL path to your WarehouseCoffeeBeanInventory WSDL should be documented in your Team Information handout you received with this lab. The above command will generate RPG and C files because the RPG stub transparently uses the C stub. The files will be stored in directory specified for the –o option. A service program, INVENTRYxx/WCBISTUB will be created from the generated stub code. A successful invocation of the wsdl2ws.sh tool will look like the following: Page 54 of 60
  55. 55. o2. Let us examine what is generated by the wsdl2ws.sh tool Issue the following commands withinQShell: oa. cd /INVENTRYxx ob. ls You should see the following files displayed in the QSHELL output: ORDERINVENTORYInput.c ORDERINVENTORYInput.h ORDERINVENTORYResult.c ORDERINVENTORYResult.h WarehouseCoffeeBeanInventoryPortType_util.rpgle WarehouseCoffeeBeanInventoryPortType_util.rpgleinc WarehouseCoffeeBeanInventoryPortType_xsdtypes.rpgleinc WarehouseCoffeeBeanInventoryPortType.c WarehouseCoffeeBeanInventoryPortType.cl WarehouseCoffeeBeanInventoryPortType.h WarehouseCoffeeBeanInventoryPortType.rpgle WarehouseCoffeeBeanInventoryPortType.rpgleinc As has been previously mentioned, when you use the tool, C stubs files will get generated. In addition, 6 files will get generated (the XXXX below is the WSDL portType name): XXXX.cl --- CL source to create service program XXXX.rpleinc --- RPG web service include XXXX.rpgle --- RPG web service implementation code XXXX_util.rpgleinc ---- RPG utility routines include XXXX_util.rpgle ---- RPG utility routines XXXX_xsdtypes.rpgleinc ---- standard data types include From the perspective of a person wanting to write an application to invoke a web service, the only files you need to look at are XXXX.rpgleinc and XXXX_xsdtypes.rpgleinc. That is it. The XXXX.rpgleinc file will contain the WSDL-defined types, the two web service stub routines: stub_create_XXXX stub_destroy_XXXX And the functions corresponding to the web service operations whose names start with "stub_op_". o c. Exit QSHELL by pressing F3=Exit Page 55 of 60
  56. 56. od. Examine the WarehouseCoffeeBeanInventoryPortType.rpgleinc file by issuing the followingCL command: edtf /INVENTRYxx/WarehouseCoffeeBeanInventoryPortType.rpgleinc You will see the following types: D ORDERINVENTORYInput_t... D DS qualified based(Template) D isNil_ORDERINVENTORYInput_t... D 1n D ITEMNO likeds(xsd_string) D REQCOUNT likeds(xsd_int) D ORDERINVENTORYResult_t... D DS qualified based(Template) D isNil_ORDERINVENTORYResult_t... D 1n D RTNCOUNT likeds(xsd_int) The types that start with the xsd_ prefix are primitive types and are defined in WarehouseCoffeeBeanInventoryPortType_xsdtypes.rpgleinc. You will also see the following function prototypes: D stub_create_WarehouseCoffeeBeanInventoryPortType... D PR 1N extproc(stub_create_WarehouseCoff+ D eeBeanInventoryPortType@) D this likeds(This_t) D stub_destroy_WarehouseCoffeeBeanInventoryPortType... D PR 1N extproc(stub_destroy_WarehouseCof+ D feeBeanInventoryPortType@) D this likeds(This_t) These functions are used to obtain and destroy a web service interface handle. Before a web service operation can be invoked, a web service interface handle needs to be obtained. The handle will be passed to functions representing the web service operations when invoking a web service operation. Below are the functions representing the web service operations: D stub_op_orderinventory_XML... D PR 1N extproc(orderinventory_XML@) D this likeds(This_t) D Value0 likeds(ORDERINVENTORYInput_t) D out likeds(xsd_string) D stub_op_orderinventory... D PR 1N extproc(orderinventory@) D this likeds(This_t) D Value0 likeds(ORDERINVENTORYInput_t) D out likeds(ORDERINVENTORYResult_t) Go to the next exercise to see how the stub code is used in an RPG application. Page 56 of 60
  57. 57. Exercise 7b: Review Client Source Code and Create Application o1. With a 5250 session, review the RPG source code for the RPG client application that consumes theWarehouseCoffeeBeanInventory web service provided by Over the Top Coffee’s supplier. oa. Issue STRPDM, Option 3. Specify file QRPGLESRC, library INVENTRYxx (where xx is your assigned student number), and member name ORDERMORE. Press Enter. ob. File member ORDERMORE will be displayed. Open the ORDERMORE source code for editing using Option 2=Edit and notice the following statements. WsStub.endpoint = http://<hostname>:<port>/web/+ services/WarehouseCoffeeBeanInventory; Action Required: Replace the <hostname> and <port> variables with the hostname and port information for your <WSERVICEyy> web services server. This information can be found in the Team Information handout you received with this lab. The statements of interest in the file are the following: stub_create_WarehouseCoffeeBeanInventoryPortType(WsStub) – the function call obtains a handle to the web service interface that is capable of communicating with the WarehouseCoffeeBeanInventory web service. stub_op_orderinventory(WsStub:Input:Result) – this function call results in web service request being sent out to web service and returns any response. Note that it is called multiple times since the code is in a loop. stub_destroy_WarehouseCoffeeBeanInventoryPortType(WsStub) – this function call destroys the web service interface handle. oc. Press F3=Exit and save the updated source file member. Page 57 of 60
  58. 58. o2. With a 5250 session, compile the RPG source code for the RPG client application that consumesthe WarehouseCoffeeBeanInventory web service provided by Over the Top Coffee’s supplier. Do not forgetto replace INVENTRYxx with your assigned team library in the following commands. oa. ADDLIBLE INVENTRYxx ob. CRTRPGMOD MODULE(INVENTRYxx/ORDERMORE) INCDIR(/INVENTRYxx) SRCFILE(INVENTRYxx/QRPGLESRC) DBGVIEW(*SOURCE) oc. CRTPGM PGM(INVENTRYxx/ORDERMORE) MODULE(INVENTRYxx/ORDERMORE) BNDSRVPGM(QSYSDIR/QAXIS10CC INVENTRYxx/WCBISTUB)The one thing to note when creating the RPG application is the two service programs that are bound towhen creating the program. QSYSDIR/QAXIS10CC is the web service client engine that handles all theserialization and deserialization of SOAP messages, and the sending and receiving of SOAP messages overthe HTTP and HTTPS transports. The other service program, INVENTRYxx/WCBISTUB, is the serviceprogram that is created by the wsdl2ws.sh tool and contains the stub code that the tool generates. Page 58 of 60
  59. 59. Exercise 7c: Consume the WarehouseCoffeeBeanInventory Web Service o1. With a 5250 session, view Over the Top Coffee’s current inventory items by calling their in-house5250 "Green Screen"Coffee Bean Inventory application and reviewing how many in stock and on orderitems they have for each inventory item by issuing the following commands from a command line: oa. ADDLIBLE LIB(INVENTRYxx) ob. CALL PGM(COFFEE) Note: For most inventory items, the In Stock Amount plus the Quantity on Order Amount do not currently add up to a sum of 25. Press F3 or F12 to exit the example Coffee Bean Inventory application’s display screen. o2. Now let us call our RPG client application (ORDERMORE) from a command line to order moreinventory items for Over the Top Coffee. Anytime a coffee item’s Total Quantity is less than 25, morecoffee will be ordered to get that total amount equal to 25. Normally this type of program would be runfrom a batch job running at night, however you are going to call this program interactively. Remember: Total Quantity = In Stock Amount + Quantity on Order AmountIssue the following commands from a command line: oa. ADDLIBLE LIB(INVENTRYxx) ob. CALL PGM(ORDERMORE) Page 59 of 60
  60. 60. o3. Now call Over the Top Coffee’s in-house 5250 “Green Screen” Coffee Bean Inventory Applicationagain to see if each coffee item’s Total Quantity is equal to or greater than 25 now that the order morecoffee application (ORDERMORE) was called. Remember when the order more coffee application(ORDERMORE) was called it consumed the WarehouseCoffeeBeanInventory web service to order moreinventory item’s from Over the Top Coffee’s supplier. Issue the following commands from a commandline: oa. ADDLIBLE LIB(INVENTRYxx) ob. CALL PGM(COFFEE) Note: If you now add up the In Stock Amount plus Quantity on Order Amount for each coffee inventory item, they should now add up to a Total Quantity value of 25 or greater.** END OF EXERCISE 7 ** Page 60 of 60

×