Skip navigation.
Downloads | Product Documentation | Support

Client Application Developer's Guide

# Exposing Data Services through Web Services

This chapter describes how to expose data services as standard web services. It covers these topics:

- Exposing Data Services as Web Services
- Adding a Liquid Data Control to a Web Service Project
- Creating a Web Service From a Liquid Data Control

# Exposing Data Services as Web Services

Using WebLogic Workshop and a Liquid Data control, you can easily add a web service wrapper to a data service. Doing so gives your data services the benefits of standard web service features, including loose client/server coupling, UDDI capability and WS-Security. WS-Security is particularly useful because it provides encryption-based, message-level security for your data.

Exposing data services as web services can make your data service information accessible to a wide variety of client types including other web services, .NET, or any non-Java application. Figure 6-1 illustrates the relationship between these client types and the Liquid Data data services layer.

Figure 6-1 Web Service Clients

To expose data services through a web service interface, add the Liquid Data control to a web service project in WebLogic Workshop. Then add data service functions from the control to your web service. The web service function needs only to pass through the results of the data service function, as shown in the following sample of generated code:

>     public class myCustomerWS implements com.bea.jws.WebService {
>     ...
>       public dataServices.payments.CustomerDocument getCustomer(int p0) {
>             return customerDsCtrl.getPayments(getCustomer(p0)); }
>     }

You can then generate a WSDL from the web service by right-clicking on the WSDL (`.jws` file). Once deployed, the data service function can be used from clients applications just like any other web service deployed to the WebLogic server. Keep in mind that data is returned from Liquid Data as standard SOAP-encased XML data, not as service data objects.

Note: This chapter focuses on how to expose data services through a standard web service interface. For more information on consuming WebLogic web services, see Invoking Web Services in Programming WebLogic Web Services in the WebLogic Platform documentation.

# Adding a Liquid Data Control to a Web Service Project

To add a Liquid Data control to an existing Web Service file (`.jws`), perform the following steps:

1. Make sure the WebLogic Server is running.
2. In WebLogic Workshop, open the existing Web Service `.jws` file.
3. Click the Design View tab on the Web service.
4. In the graphical representation of the Web service, right-click and select Add Control —> Liquid Data as shown in Figure 6-2.

Figure 6-2 Adding a Liquid Data Control to a Web Service

5. In the Insert Control Wizard, enter a variable name for the control (STEP 1 in the dialog in Figure 6-3). The variable name can be any valid variable name that is unique in the Web Service.
6. In the Insert Control Wizard, either browse to an existing Liquid Data control (it must be in the same project as the Web Service) or click the Create a New Liquid Data Control button.
7. If you want the control to be a factory, check the Make This a Control Factory button as shown in Figure 6-3. If the control is a factory, it will create multiple instances at runtime. Otherwise, requests to the control are queued and each request for a given query must complete before another can begin.

Figure 6-3 Insert Control Wizard

8. If Liquid Data is deployed on a WebLogic Server that is running on a separate domain from Workshop, click remote (in STEP 3 of the Insert Control Wizard dialog). For details about specifying a local or remote Liquid Data server, see Step 5: Enter Connection Information to the WebLogic Server on page 5-11 in Accessing Data Services from Workshop Applications.
9. Click the Create button on the Insert Control Wizard.
10. If you created a new control, in the Select Liquid Data Queries dialog select the data service functions you want from the left pane and click Add as shown in Figure 6-4. When done, click Finish. At that point, the Liquid Data Control (`.jcx`) file is generated, with a call for each selected function.

The `LiquidDataControl.jar` file is copied into the `Libraries` directory of your application when you finish creating the Liquid Data Control.

Figure 6-4 Liquid Data Control Wizard—Select Queries

11. Now add functions to the callable interface of the web service. To add a data service function to the web service, choose the function from below the control node in the Data Palette then drag and drop the function onto the left side of the web service diagram as illustrated in Figure 6-5.

Figure 6-5 Adding a Function to the Web Service

12. Click the test button (or select Debug —> Start from the Workshop menu) to test your web service.

From there, you can work with the Liquid Data web service as you can any other web service in WebLogic Workshop. You can generate a WSDL file for it, and more.

For example, to create a WSDL file, right-click the `.jws` file in the application tree and choose Generate WSDL File from the menu.

For more information, see:

http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webservices.html

# Creating a Web Service From a Liquid Data Control

Perform the following steps to generate and test a web service from a Liquid Data Control. You can create either conversational or stateless web services with data service. The following instructions describe how to create a conversational web service.

1. Select a Liquid Data Control (`.jcx`) file, right-click, and select Generate Stateless JWS File. Workshop generates the `.jws` Java Web Service file for your Liquid Data control.
2. Select your Web Service project, right-click, and select Build Project. Workshop builds a Web Service project.
3. When the build is complete, double-click the `.jws` file to open it.
4. On the Design View of the Web Service, notice the `startTestDrive` and `finishTestDrive` methods, as well as a method for each of the queries you specified in the Liquid Data Control Wizard.
5. Click the test button (or select Debug —> Start from the Workshop menu) to test the web service.
6. Click the `startTestDrive` button to start the conversation for the Web Service.
7. Click the Continue this Conversation link (in the left corner of the test page).
8. Enter values for any query parameters (if the query has parameters) and click the button with the name corresponding to the query you want to execute.

The Web Service executes the query and the results are returned to a test browser.

9. If you want to run the query again or run other queries in the Web Service, click Continue this Conversation, enter any needed parameters and click the button with the name corresponding to the query you want to execute.
10. To end the Web Service conversation, click the Continue this Conversation link and then click the `finishTestDrive` button.

Once deployed, the web service can be used just like any other web service deployed on WebLogic servers. For more information, see Invoking Web Services in Programming WebLogic Web Services in the WebLogic Server documentation.