Web Services in DataFlex
Introduction
If you haven't worked through the complete Quick Start section of the Tutorials, we suggest that you at least work through the following sections:
Web Services provide a mechanism for making application logic accessible using standard Internet protocols. A Web Service allows programs to exchange data and access application logic over the Internet. Central to the concept of web services is neutrality; web services must be platform neutral, protocol neutral, and language neutral.
The standard for web service information exchange is SOAP (Simple Object Access Protocol). W3C (SOAP 1.1 Specification) describes SOAP as follows:
“SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML-based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.”
While SOAP can potentially be used with other protocols, the current focus of SOAP within the industry and, therefore, within DataFlex, is using SOAP over HTTP (i.e., over the Internet).
DataFlex Web Services also support returning data in JSON format. JSON is often used instead of SOAP together with Ajax-based web applications.
The focus of Web Services within DataFlex will be the exchange of information based on remote procedure calls. Restated, a web service allows you to create a function that can be called remotely, over the Internet, by any application in the world. This function on the server can reside on any platform and be written in any language. The application calling the function can reside on any platform and be written in any language.
Web services are created in an application that runs on a web server. They are “called” by a remote application. The web service on the server will be referred to as a Server Side Web Service. The application calling the service does this by calling a method in a local object that is referred to as a Client Side Web Service. The client is responsible for making the actual remote request.
DataFlex provides support for both Server and Client side web services. While this means that you can use the DataFlex Web Application Server to create web services that can be accessed by any DataFlex Windows application, it is important to understand that the use of web services goes far beyond this capability. On the server side, a DataFlex web service can be accessed by any application. On the client side, a DataFlex application can access any web service.
Ease of Use
One of the primary goals of Web Service implementation in DataFlex was simplicity. A developer should be able to create and use web services without needing to understand all of the underlying complexities that make them work. If you can create a function, you can create a web service. If you can call a function, you can access a web service.
If you are new to web services, you may wish to jump right in and start building and using web services. Start by creating a web service within a web application. You should be able to do this without having to deal with any of the underlying complexities that comprise web services (SOAP, XML, WSDL, Schemas, Serialization, etc.).
After you’ve created a web service and tested it using the test service pages, try using this service by building a client web service class and object. You will create your class by pointing to the web service description and telling DataFlex to create a subclass. An object based on this class can then be dropped into your application and can access the service operations just like you would access any method within your application. Again, this can all be done without needing to deal with the underlying implementation.
After you’ve succeeded in connecting to the web service you created, you may wish to find some other web service and try connecting to that. A good place to find web services is x-methods (XMethods).