Skip to content

Client Side Web Services

Within a DataFlex Windows application, a web service is accessed by:

  1. Generating a sub-class that provides access to a web service.
    This class, which will be automatically generated by accessing the web service’s description, will contain a method interface (function name and parameters) that matches the interface of the actual web service.

  2. Creating an object within your program that is based on this sub-class.
    This is accomplished by selecting the web service class from the Studio’s control palette and dropping it into your view.

  3. Calling the function within this client object.
    The object will convert your function into a SOAP request and send it to the server. When it receives a response from the server, it will unpack the SOAP response and place the data into the function’s return value.

Creating a Client Web-Service Class

A new class, cClientWebService, is used as the basis for all client web services. This class knows how to handle generic SOAP messages. Each web service has its own definition, and therefore each web service will be represented on the client side as a sub-class based on cClientWebService. These custom classes contain functions that correspond to the functions that exist in the actual service.

A tool, the Web-Service Client Class Generator, is provided for automatically creating client web service classes. This class generator requires that you provide it with the location of a web service’s description (its WSDL location). The tool will parse the WSDL document and create a sub-class based on that information. It will create the class and all additional files required to integrate the class directly in the Studio so that it can be accessed from the Studio’s Control Palette.

Adding a Client Web Service Object to Your Application

Once a web service client sub-class has been created, it can be added to any program in the same manner that any object is added to a DataFlex application. You will need to find your web service class in your Control Palette, grab it, and drag and drop it into your component.

Calling a Web Service

If you look at the client web service object that was created, you will see that the service’s interface is shown as part of the object’s documentation. These interfaces will appear as standard functions consisting of a function name, parameter data types and names, and a return data type. A web service is called by sending a message to this object (i.e., you just call the function). The object will take this local function call, turn it into a proper SOAP request, and make the needed HTTP request to the server. The server will process the request and send back a SOAP response. The client object will take this response, parse it, and set up the return value or, if needed, handle any error messages. As a developer, you will see none of this. You will simply be calling a method within an object and getting a return value.

See Also

Web Services