Samples Tutorial

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Accessing Data Services

One of the data sources available with the samples installed with ALDSP is a Web service that provides customer credit rating information. In this lesson, you will generate a physical data service that can be integrated into the CustomerProfile logical data service.

The process for creating a data service based on a Web service is similar to importing relational database source metadata. The difference is that ALDSP uses the WSDL (Web services description language) metadata to introspect the Web service's operation and generate the data service.

 


Objectives

After completing this lesson, you will be able to:

 


Overview

A Web service is a self-contained, platform-independent unit of business logic that is accessible to other systems on a network. The network can be a corporate intranet or the Internet. Other systems can call the Web services' functions to request data or perform an operation.

Web services are increasingly important resources for global business information. Web services can facilitate application-to-application communication and are a useful way to provide data, like stock quotes and weather reports, to an array of consumers over a corporate intranet or the Internet. But they take on additional new power in the enterprise, where they offer a flexible solution for integrating distributed systems, whether legacy systems or new technology.

WSDLs are generally publicly accessible and provide enough detail so that potential clients can figure out how to operate the service solely from reading the WSDL file. If a Web service translates English sentences into French, the WSDL file will explain how the English sentences should be sent to the Web service, and how the French translation will be returned to the requesting client.

 


6.1 Importing a Web Service Project into the Application

When you want to use an external Web service from within WebLogic Workshop, you should first obtain that service's WSDL file. In this exercise, you will use the WSDL for a Web service project that was created in WebLogic Workshop.

Objectives

In this exercise, you will:

Instructions

  1. Import a Web service into the ALDSP-enabled application, by completing the following steps:
    1. Choose File Arrow symbol Import Project. The Import Project - New Project dialog box opens.
    2. Select Web Service Project.
Caution: Make sure that you select a project of type Web service. If you select another project type, then the CreditRatingWS application may not work correctly.
    1. In the directory field, click Browse.
    2. Navigate to <beahome>\weblogic81\samples\liquiddata\EvalGuide
    3. Select CreditRatingWS and click Open.
    4. Make sure that the Copy into Application directory checkbox is selected.
    5. Click Import and then click Yes when the confirmation message to update your project appears.
    6. Figure 6-1 Import Web Services Project


      Import Web Services Project

  1. In the Application pane, verify that the following items were imported:
  1. Open CreditRatingDBTest.jws in Design View. This file is located in CreditRatingWS\controls. The Web service diagram should be as displayed in Figure 6-3.
  2. Figure 6-3 Design View of Credit Rating Web Service


    Design View of Credit Rating Web Service

  3. Test the imported Web service, by completing the following steps:
    1. Click the Start icon, or press Ctrl + F5, to open Workshop Test Browser.
    2. Enter CUSTOMER3 in the customer_id field.
    3. Click getCreditRating. The requested information displays in Workshop Test Browser.
    4. Figure 6-4 Workshop Test Browser


      Workshop Test Browser

    5. Scroll down to the Service Response section and confirm that you can retrieve credit rating information for CUSTOMER3.
    6. Figure 6-5 Web Service Results


      Web Service Results

 


6.2 Importing Web Service Metadata into a Project

WSDL is a standard XML document type for describing an associated Web service so that other software applications can interface with the Web service. Files with the .wsdl extension contain Web service interfaces expressed in the Web Service Description Language (WSDL).

A WSDL file contains all the information necessary for a client to invoke the methods of a Web service:

Objectives

In this exercise, you will:

Instructions

  1. In Workshop Test Browser, scroll to the top of the window.
  2. Click the Overview tab.
  3. Figure 6-6 Workshop Test Browser Overview


    Workshop Test Browser Overview

  4. Click Complete WSDL.
  5. Copy the WSDL URI, located in the Address field. The URI is typically: http://localhost:7001/CreditRatingWS/controls/CreditRatingDBTest.jws?WSDL=
  6. Figure 6-7 WSDL URI


    WSDL URI

  7. Close Workshop Test Browser.
  8. In Workshop: Close all open files (File Arrow symbolClose All Files).
  9. Create a new folder within the DataServices project folder, and name it WebServices.
  10. Import Web service source metadata into the WebServices folder, by completing the following steps:
    1. Right-click the WebServices folder.
    2. Choose Import Source Metadata.
    3. Choose Web Service from the Data Source Type drop-down list. Then click Next.
    4. Figure 6-8 Web Service Data Source Type


      Web Service Data Source Type

    5. Paste the copied WSDL URI into the URI or WSDL File box and click Next.
    6. Figure 6-9 Paste the URI


      Paste the URI

    7. Expand the CreditRatingDBTestSoap and Operations folders.
    8. Select getCreditRating operation, and click Add to populate the Selected Web Service Operations pane.
    9. Click Next.
    10. Figure 6-10 Selected Web Service Operations


      Selected Web Service Operations

    11. Do not select the getCreditRating procedure as the side effect procedure in the Select Side Effect Procedures dialog box. Click Next.
    12. Figure 6-11 Data Service Procedure Option (Unselected)


      Data Service Procedure Option (Unselected)

    13. Review the Summary information, which includes:
      • Function name.
      • XML type, for Web service objects whose source metadata will be imported.
      • Name, for each data service that will be generated from the source metadata. (Any name conflicts appear in red and must be resolved before proceeding. However, you can modify any data service name.)
      • Add to Existing Data Service, to add the function to an existing data service.
      • Location, where the generated data service(s) will reside.
    14. Click Finish.
    15. Figure 6-12 Web Services Summary


      Web Services Summary

  11. Open getCreditRatingResponse.ds in Design View. This file is located in DataServices\WebServices.
  12. Confirm that there is a function called getCreditRating().
  13. Figure 6-13 Web Service Function Added


    Web Service Function Added

 


6.3 Testing the Web Service via a SOAP Request

Extensible Markup Language (XML) messages provide a common language by which different applications can talk to one another over a network. Most Web services communicate via XML. A client sends an XML message containing a request to the Web service, and the Web service responds with an XML message containing the results of the operation. In most cases these XML messages are formatted according to Simple Object Access Protocol (SOAP) syntax. SOAP specifies a standard format for applications to call each other's methods and pass data to one another.

Note: Web services may communicate with XML messages that are not SOAP-formatted. The types of messages supported by a particular Web service are described in the service's WSDL file.

Objectives

In this exercise, you will:

Instructions

  1. Build the DataServices project.
  2. Open getCreditRatingResponse.ds in Test View. (This file is located in DataServices\WebServices.)
  3. Select getCreditRating(x1) from the Function drop-down list.
  4. Enter the following SOAP body in the Parameter field:
  5. <getCreditRating xmlns="http://www.openuri.org/">
      <customer_id>CUSTOMER3</customer_id>
    </getCreditRating>
Note: An alternative to adding the SOAP body in the parameter field is to use a template for the input parameter by clicking Insert Template.
Figure 6-14 SOAP Parameter

SOAP Parameter

  1. Click Execute.
  2. Review the results, which should be similar to those displayed in Figure 6-15 (Rating:600, CustomerID: CUSTOMER3). Notice that only two data elements are returned: the customer ID and the credit rating for that customer.
  3. Figure 6-15 Web Service Results


    Web Service Results

 


6.4 Invoking a Web Service in a Data Service

You are now ready to use the Web service to provide the data that populates the CustomerProfile logical data service.

Objectives

In this exercise, you will:

Instructions

  1. Open CustomerProfile.ds file in Source View. The file is located in DataServices\CustomerManagement.
  2. In the Source View, add the following namespace definitions, in addition to the ones already defined for the CustomerProfile data service:
  3. declare namespace ws1="ld:DataServices/WebServices/getCreditRatingResponse";
    declare namespace ws2 = "http://www.openuri.org/";
Note: The "1" in "ws1" is a numeral.
  1. Open the creditRatingXQuery.txt file, located in <beahome>\weblogic81\samples\LiquidData\EvalGuide in a text editor.
  2. Copy all the code from the creditRatingXQuery.txt file.
  3. In the CustomerProfile.ds file, expand the getAllCustomers() function.
  4. Insert the copied text into the section where the empty CreditRating complex element is located. The empty complex element is as follows:
  5. <creditrating>
       <rating></rating/>
       <customer_id></customer_id>
    </creditrating>
Note: The copied code replaces everything after: </orders> and before <valuation>.
  1. Confirm that the <creditrating> code is as displayed in Figure 6-16.
  2. Figure 6-16 Credit Rating Source Code


    Credit Rating Source Code

  3. View the results, by completing the following steps:
    1. Open CustomerProfile.ds in XQuery Editor View.
    2. Select getAllCustomers() from the Function dropdown list. The function should be similar to that displayed in Figure 6-17.
    3. Figure 6-17 XQuery Editor View of a Web Service Being Invoked


      XQuery Editor View of a Web Service Being Invoked

    4. Open CustomerProfile.ds in Design View. The Web service is listed as a data source, in the right pane of the diagram.
    5. Figure 6-18 Design View of a Web Service Invoked in a Data Service


      Design View of a Web Service Invoked in a Data Service

  4. Test the data service by completing the following steps:
    1. Build the DataServices project.
    2. Open CustomerProfile.ds in Test View.
    3. Select getCustomerProfile(CustomerID) from the Function drop-down list.
    4. Enter CUSTOMER3 in the xs:string CustomerID field.
    5. Click Execute.
    6. Confirm that you can retrieve the credit rating for Customer 3.
    7. Figure 6-19 Customer Profile Data Integrated with Web Service Credit Rating Data


      Customer Profile Data Integrated with Web Service Credit Rating Data

  5. Import the CreditRatingExit1.java file from the EvalGuide folder:
    1. Right-click the WebServices folder.
    2. Select Import option.
    3. Navigate to <beahome>\weblogic81\samples\LiquidData\EvalGuide and select file CreditRatingExit1.java for import. Click Import.
    4. Build the DataServices project.
    5. Open getCreditRatingResponse.ds in Design View. Set the UpdateOverride Class property in the Property Editor to WebServices.CreditRatingExit1. (If the Property Editor is not open, you can select it using the View menu Property Editor option.)
    6. Click the browser symbol in the Update Override Class field.
    7. Navigate to the DataServices.jar -> WebServices folder.
    8. Select the CreditRatingExit1.class file. Click open.
    9. Figure 6-20 Selecting the Update Override Class


      Selecting the Update Override Class

  6. (Optional) Open the Output window to view the data sources used to generate the Test View results. You should see the following statement, which indicates that data was pulled from the invoked Web service:
Note: To perform this step, you need to enable auditing in the ALDSP Console.
Figure 6-21 Viewing the Data Sources in the Output Window

Viewing the Data Sources in the Output Window

 


Lesson Summary

In this lesson, you learned how to:


  Back to Top       Previous  Next