A Data Service Control can be used to access data through a page flow, Web service, or business logic. In the previous lesson, you created a Data Service Control and used it within a Web application's page flow. In this lesson, you will use that same Data Service Control to generate a .wsdl for a Web service that can invoke data service functions.
Objectives
After completing this lesson, you will be able to:
Use a Data Service Control to generate a Web service for a data service.
Test the generated Web service and invoke data service functions through the Web service interface.
Generate a .wsdl file for Web service clients.
Overview
A Web service is a set of functions packaged into a single entity that is available to other systems on a network. The network can be a corporate intranet or the Internet. Other systems can call these functions to request data or perform an operation.
Web services are a useful way to provide data to an array of consumers over the Internet, like stock quotes and weather reports. But they take on a new power in the enterprise, where they offer a flexible solution for integrating distributed systems, whether legacy systems or new technology.
9.1 Generating a Web Service from a Data Service Control
In the previous lesson, you created a Data Service Control, which enabled WebLogic Workshop to generate a Java Control Extension (.jcx) file. This file contains the underlying data service's method calls. In this exercise, you will use that Data Service Control to generate a Web service.
Objectives
In this exercise, you will:
Generate a stateless Web service interface, through which you can access the Data Service Control.
Test the Web service to determine that it returns customer profile and order information.
Instructions
Expand the CustomerManagementWebApp and controls folders.
Right-click the CustomerData.jcx control.
Choose Generate Test JWS (Stateless). A new file, CustomerDataTest.jws, is generated. With this Java Web Service (.jws) file, the Data Service Control methods are now available through a Web service interface.
Figure 9-1 Java Web Service File
Open the CustomerDataTest.jws file in Source View.
Click the Start icon (or press Ctrl+F5). Workshop Test Browser opens.
Enter CUSTOMER3 in the string CUSTOMER ID field.
Figure 9-2 Workshop Test Browser: Web Service
Click getCustomerProfile. The customer profile and order information for Customer 3 is retrieved.
View both the "Returned from" and "Service Response" results, which should be similar to that displayed in Figure 9-3.
Figure 9-3 Web Service Test Results
Close Workshop Test Browser.
9.2 Using a Data Service Control to Generate a WSDL for a Web Service
You can use the Java Web Service file to generate a WSDL. A WSDL file contains all of the information necessary for a client to invoke the methods of a Web service:
The data types used as method parameters or return values.
The individual methods names and signatures (WSDL refers to methods as operations).
The protocols and message formats allowed for each method.
The URLs used to access the Web service.
Objectives
In this exercise, you will:
Generate a .wsdl file, based on the Data Service Control.
(Optional) View the .wsdl file's structure and source code.
Instructions
Right-click the CustomerDataTest.jws control.
Choose Generate WSDL File. The CustomerDataTestContract.wsdl is generated, which can be used by other Web service clients.
Figure 9-4 New WSDL File
(Optional) Open the CustomerDataTestContract.wsdl file and explore the document structure and source code.
Figure 9-5 Document Structure
Lesson Summary
In this lesson, you learned how to:
Use a Data Service Control to generate a Web service for a data service.
Test the generated Web service and invoke data service functions through the Web service interface.