One of the operations available from NewCo Web service enables you to get the customer name for a given customer number. The Progress eLearning Community Web page includes a link to a program, InvokeValideCustomer.w, that uses that operation:
The following excerpts from InvokeValideCustomer illustrate how to consume a Web service from ABL. In the main block, the application first creates a server and connects to the Web service by specifying the location of the WSDL file for run-time access and the name of a port type (persistent procedure) on the server:
CREATE SERVER hServer.
lReturn = hServer:CONNECT("-WSDL http://wstraining.progress.com/wsa/wsa1/
wsdl?targetURI=urn:OpenEdgeServices:NewCoService
-Port NewCoServiceObj").
IF lReturn = NO THEN DO:
MESSAGE
"Could not connect to WebService server"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN.
END.
Note: You only need to specify -Port when the WSDL file contains more than one valid service and port. For information on the full range of binding options for Web services, see Connecting to OpenEdge SOAP Web Services from ABL.
If the server connects successfully, the application uses the RUN statement syntax to create the Web service proxy procedure object and map it to the port type (NewCoServiceObj) that defines the ValidateCustomer operation for the Web service:
RUN NewCoServiceObj SET hPortType ON SERVER hServer.
IF NOT VALID-HANDLE(hPortType) THEN DO:
MESSAGE
"Could not establish portType"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
APPLY "CLOSE":U TO THIS-PROCEDURE.
RETURN.
END.
When you click Enter, the application invokes the ValidateCustomer operation, passing in the value in the customer number field and displaying the return value in the customer name field:
ON CHOOSE OF bDoWork IN FRAME DEFAULT-FRAME
DO:
ASSIGN iCustNum.
/* Invoke ValidateCustomer */
RUN ValidateCustomer IN hPortType (INPUT iCustNum, OUTPUT cCustName)
NO-ERROR.
/* this procedure checks for errors in the previous call */
RUN ErrorInfo (OUTPUT lerr).
IF NOT lerr THEN DO:
DISPLAY cCustName WITH FRAME default-frame.
END.
END.
When you click Done, the application deletes the hPortType procedure object, unbinds the Web service from the server, and then deletes the server object:
This sample shows the similarity between basic AppServer and Web service access using synchronous interaction with the client. Another common feature between client interaction with an AppServer and client interaction with a Web service is the ability to invoke procedures asynchronously. For information on when and what you need to do to invoke Web service requests asynchronously, see Managing asynchronous requests.
Note: This sample is not available on the Documentation and Samples (doc_samples) directory of the OpenEdge product DVD or the Progress Documentation Web site.