Skip to content

Creating a Web Service Object

Creating a web service WSO component consists of the following steps:

  • Create a New WSO component
  • Create your functions (operations) that you wish to make public
  • Publish these functions
  • Document the operations and the service
  • Set the name of the service
  • Save the component and add it to your web application

Here are these same steps, described in more detail:

  1. In the Studio, select the File/New/Web Object… file menu option. You may also access Web Objects using the New button in the toolbar.

  2. Select Web Service Object. This will create a new Web Service component.

  3. Using the Studio’s code explorer, open the source inside of your Web Service object and write your code. To keep it simple, we suggest that you create a simple “Hello World” function to start with. This function may look like the following:

Function Hello string sName returns string
    string sReply
    Move ("Hello," * sName - ", how are you today") to sReply
    Function_Return sReply
End_Function

Note that this is a very simple example. A WSO object is a business process object and is capable of performing sophisticated operations. You can create data-dictionary object structures within the WSO and use web-service operations to store and retrieve data from your DDOs. You can create additional private processing methods within your WSO, which can be called by your public web-service operations. Additionally, you can choose to have your public operations access program logic outside of your WSO. Think of a web-service operation as a portal into your application, your application logic, and your application data.

  1. A WSO may contain many functions and not all of them should be exposed as a web service. You expose a web-service method by publishing it. You do this by finding that method in the Code Explorer and selecting Publish from the right-click context menu. Alternatively, you can also add the Published meta-data tag manually. For example:
{ Published = True }
Function Hello string sName returns string
    string sReply
    Move ("Hello," * sName - ", how are you today") to sReply
    Function_Return sReply
End_Function
  1. You may create an optional but recommended comment for any web-service function. This comment will be published as part of the service’s description in the WSDL file. The comment is specified using the Description meta-data tag immediately above the function/procedure. For example:
{ Published = True }
{ Description = "This function says hello" }
Function Hello string sName returns string
    string sReply
    Move ("Hello," * sName - ", how are you today") to sReply
    Function_Return sReply
End_Function
  1. You will want to create a description for the entire web service to be published as part of the service’s description. You can do this by finding the following source code and replacing it with meaningful information. Note that this source is broken up into multiple lines to demonstrate how to create long, yet readable descriptions within the edit area.
Set psDocumentation to ;
    ("DataFlex Web Service .... " +;
     " ... " +;  
     "documentation")
  1. You need to set the service name. This name uniquely identifies the service within your application and is used by clients to access the service. For example, if the name of your service was HelloService in an application whose virtual directory was http://localhost/MyApplication, the service would be accessed with the URL http://localhost/MyApplication/HelloService.wso. The name is set with the psServiceName property in the Studio’s property page. The default name is tempService, which you will want to change.

  2. Save the component. Before you can test or use this service, it must be added to your application. As you save the WSO, you will be allowed to automatically add the WSO component to your WebApp.src application. Do so.

See Also