Skip to content

Using a Client Web Service in a Component

Once a client web-service class is created, you will use it by creating an object instance of this class in your program. Load an existing view or create a new view. Open the Class Palette and locate the web-service component in the group where you placed it.

Find the component you want and drag it into your view. You have now created an object based on this class.

Load the code explorer and click on the new object. The commented source code for this object will appear and provide you with useful information. These comments may look like the following:

// Web Service Class is defined in cWSHelloService.pkg
//
// Interface:
//
// Function wsHello string sFirst string sLast returns string
// Function wsGoodbye string sFirst string sLast returns string
//
// phoSoapClientHelper
//     Setting this property will pop up a view that provides information
//     about the Soap (xml) data transfer. This can be useful in debugging.
//     If you use this you must make sure you USE the test view at the top
//     of your program/view by adding:   Use WebClientHelper.vw // oClientWSHelper
// Set phoSoapClientHelper to oClientWSHelper

These comments tell us that the service supports two operations, wsHello and wsGoodbye, and that these are passed two strings and return a string. You may also wish to look at the actual client class. The class package name is listed. You can easily open this class by moving your cursor over the name and selecting “Open File Under Cursor” from your context menu. The class will contain all the code generated by the class generator. If the WSDL contained comments and descriptions, these will all be listed in the class.

To use the object in your program, you need to send a message to it. For example, you could create an OnClick method in your button that calls a web-service operation as follows:

Procedure OnClick
    String sFirst sLast sReply
    Get Value of oFirst to sFirst
    Get Value of oLast to sLast
    Get wsHello of oWSHelloService sFirst sLast to sReply
    Set Value of oReply to sReply
End_Procedure // OnClick

You have now accessed a web-service within your application.

All client web-service methods are prefaced with ws. This is to ensure that the name of a method does not collide with any reserved words within your existing application. It also makes it easy to recognize that calls within your application to ws methods are calling web-services.

All client web-service class names are prefaced with cWS. This is to ensure that there are no class naming collisions. This also makes it easy to locate and identify client web-service classes.

See Also