Chapter 9. IBM Web Services Client for ILE (RPG, C, C++, COBOL) 209
13.Examine the generate code and note C externalized functions (see Figure 9-19):
Functions relating to Web service client proxy
Functions relating to Web service methods
These functions will be used by an RPG program to invoke the Web service.
Figure 9-19 Generated C code for RERSERVEFLIGHTServices.h
14.Click the RPGTEST.RPGLE tab and copy the source code from Example 9-1. Note how
the C stubs are externalized and used throughout the RPG code.
Example 9-1 RPG Source code to invoke Web Services Client for ILE
H DFTNAME(GETCINFORP)
/INCLUDE RPGINCLUDE
*******************************************
D RFLInput DS
*******************************************
D AgentNumber1 *
D CustNumber1 *
D FlightNumber1 *
D DepartDate1 *
D DepartTime1 *
D Tickets1 *
D ServiceClass1 *
D
*
D AgentNumber 9B 0
D CustNumber 9B 0
D FlightNumber 8
D DepartDate 9
D DepartTime 9
D Tickets 4F
D ServiceClass 2
*
DgetStub PR * ExtProc('get_RESERVEFLIGHTServices_+
D stub')
210 Building SOA-based Solutions for IBM System i Platform
D pEndpoint * Value
*
*
DgetRFlight PR * ExtProc('reserveflight_XML')
D pRFLWS * Value
D pRFLInput * Value
*
*
DdestroyStub PR ExtProc('destroy_RESERVEFLIGHTServi+
D ces_stub')
D pCityInfoWS * Value
*
DdestroyParm PR ExtProc('axiscAxisDelete')
D value * Value
D description 9B 0 Value
*
*
*
D RFLWS S *
D RFLInput1 S *
D Endpoint S 100A
D pOrderXML S *
D OrderXML S 120A
D Output S 52A
*
C eval AgentNumber = 5
C eval CustNumber = 500
C eval FlightNumber = '5191135' + X'00'
C eval DepartDate = '12/11/08' + X'00'
C eval DepartTime = '7:12 AM' + X'00'
C eval Tickets = 3
C
C eval ServiceClass = '1' + X'00'
*
C eval AgentNumber1 = %addr(AgentNumber)
C eval CustNumber1 = %addr(CustNumber)
C eval FlightNumber1 = %addr(FlightNumber)
C eval DepartDate1 = %addr(DepartDate)
C eval DepartTime1 = %addr(DepartTime)
C eval Tickets1 = %addr(Tickets)
C eval ServiceClass1 = %addr(ServiceClass)
*
C eval Endpoint = 'http://itso:9080' +
C '/WebServiceProject/services'+
C '/RESERVEFLIGHTServices' + X'00'
C eval RFLWS = getStub(%Addr(Endpoint))
C eval RFLInput1 = %Addr(RFLInput)
C eval pOrderXML = getRFlight(
C RFLWS :
C %addr(RFLInput1))
C eval OrderXML = %str(pOrderXML)
C if (OrderXML <> *blanks)
C movel *blanks field 52
C eval Output = 'The order information: '
Chapter 9. IBM Web Services Client for ILE (RPG, C, C++, COBOL) 211
C eval field = %subst(OrderXML:61:7)
C*
C Output dsply
C field dsply
C else
C eval Output = 'There is no order information '
C Output dsply
C endif
C callp axiscAxisDelete(pOrderXML:XSDC_STRING)
C eval pOrderXML=*NULL
C callp destroyStub(RFLWS)
C seton lr
Web Services Client for ILE INCLUDE file for RPG
The RPGINCLUDE file has been created to import some RPG constants and RPG functions
that is common to running Web service Client in RPG Service Programs (see Example 9-2).
Example 9-2 RPGINCLUDE
* LICENSE AND DISCLAIMER
* ----------------------
* This material contains IBM copyrighted sample programming
* source code ( Sample Code ).
* IBM grants you a nonexclusive license to compile, link,
* execute, display, reproduce, distribute and prepare derivative
* works of this Sample Code. The Sample Code has not been
* thoroughly tested under all conditions. IBM, therefore, does
* not guarantee or imply its reliability, serviceability, or
* function. IBM provides no program services for the Sample Code.
*
* All Sample Code contained herein is provided to you "AS IS"
* without any warranties of any kind. THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGMENT ARE EXPRESSLY DISCLAIMED.
* SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
* WARRANTIES, SO THE ABOVE EXCLUSIONS MAY NOT APPLY TO YOU. IN
* NO EVENT WILL IBM BE LIABLE TO ANY PARTY FOR ANY DIRECT,
* INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY USE OF
* THE SAMPLE CODE INCLUDING, WITHOUT LIMITATION, ANY LOST
* PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA
* ON YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN IF WE
* ARE EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
Important: You need to adjust the value of itso:9080 for the correct values for your
System i platform and WebSphere Application Server profile values.
Note: In our example source code, we used the RPGINCLUDE file for
axiscAxisDelete(pOrderXML:XSDC_STRING) function. The function deletes the return
values after they have been processed so as not to create a memory leak for the RPG
program.
Review the WSCI-1.0.pdf for memory considerations. The file is located at
/QIBM/ProdData/xmltoolkit/WSCI-1.0-OS400/docs/WSCI-1.0.pdf and can be access
using a mapped drive or FTP.

Get Building SOA-based Solutions for IBM System i Platform now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.