180 likes | 380 Views
Accessing a Web service. Overview. When you complete this lesson you should be able to:. Describe the steps for accessing a Web service Implement the 4GL code for invoking a Web service operation. Steps for accessing a Web service. NewCo Web Service. WSDL: operations: SendOrders
E N D
Overview When you complete this lesson you should be able to: • Describe the steps for accessing a Web service • Implement the 4GL code for invoking a Web service operation
Steps for accessing a Web service NewCo Web Service WSDL: operations: SendOrders GetInvoice 2c WSDL Analyzer NewCoService.wsdl 1 3 • Development: • Understand the WSDL • Run-time: • Connect to Web service • Establish portType HANDLE • Prepare to invoke operation • cMyOrder = . . . • Invoke operation • Process result of operation • iNum = iInvoiceNum. • Disconnect from Web service • SERVER-DISCONNECT(). SERVER-CONNECT() 2a NewCoService.wsdl 2b RUN SendOrders(cMyOrder) 4a iInvoiceNum 4b
WSDL requirements for 4GL clients The WSDL must define: • The connection information for the service • The names of the port type(s) • The operations for each port type • Name • Parameter • Types of parameters • The bindings available for a service
How to use the Web service? WSDL may contain: • Documentation about the service • Documentation for each operation • Documentation about how operations can be used together Web service provider should have detailed documentation available to consumers of the Web service (provided in the WSDL or by some other means)
4GL code setting up the procedure handle /* Definitions section */ DEFINE VARIABLEhPortTypeAS HANDLE NO-UNDO. /* Main Block section */ /* get ready to invoke the operation on the service */ /* Web service connection made */ RUN NewCoService2Obj SET hPortType ON SERVER hServer. IF NOT VALID-HANDLE(hPortType) THEN DO: MESSAGE "Could not establish the portType procedure handle" VIEW-AS ALERT-BOX INFO BUTTONSOK. APPLY “CLOSE”:U TO THIS-PROCEDURE. RETURN. END.
Summary You should now be able to: • Describe the steps for accessing a Web service • Implement the 4GL code for invoking a Web service operation