Oracle SOA Suite 12c: REST-Enabling SOA with Oracle Service Bus

 

Overview

Purpose

This tutorial shows you how to REST-enable an existing Simple Object Access Protocol (SOAP) service by using Oracle Service Bus.

Time to Complete

Approximately 30 minutes

Introduction

Most existing web applications are connected through web services, which are commonly known as SOAP services. More and more users are relying on mobile devices for communication, and they’re looking for lighter ways to access enterprise information on the go. REST services are the answer for the mobile device platform, because they get rapid responses and fast access to data.

Oracle Service Bus provides a virtualization layer to support REST, which means that only proxy and business services are REST-based. These REST services invoke, or are invoked by, a Web Service Description Language (WSDL) pipeline or a split-join. REST proxy services convert the REST native payload to SOAP before invoking a pipeline or split-join, while REST business services invoked by a pipeline or a split-join convert the payload from SOAP to REST. The internal interface is based on WSDL, whereas the external business and proxy services expose REST endpoints.

In this tutorial, you REST-enable a service by using an application that validates credit cards. The application validates the requested authorization amount for the credit card number, and it returns the response in XML or JavaScript Object Notation (JSON) format, the common data formats for mobile devices.

Hardware and Software Requirements

A Windows, Mac OS X, or Linux machine that meets the system requirements for Oracle SOA Suite 12c

Note: This tutorial was created with Windows 7. If you use another operating system, the paths may be different.

Prerequisites

Before starting this tutorial, you should have:

 

Opening and Deploying a Composite Application

In this section, you open and deploy a composite application to Integrated WebLogic Server.

  1. Open Oracle JDeveloper 12c, click the Applications tab, and select e2e-1201-composites.

    ValidatePayment composite
  2. On the Applications tab, right-click ValidatePayment, select Deploy, and then select ValidatePayment.

     Deploy ValidatePayment
  3. On the Deploy ValidatePayment page, enter, select, or verify the following values on the specified pages, click Next on each page, and then click Finish on the Summary page after you review your selections:

    • Deployment Action page: Select Deploy to Application Server.
    • Deploy Configuration page: Enter or verify 1.0 for the New revision ID field, and select Overwrite any existing composites with the same revision ID.
    • Select Server page: Select IntegratedWebLogicServer.
    • SOA Servers page: Verify that the default server is running and selected.

    The Summary page should look like the following:

    Summary
  4. On the Deployment - Log tab, verify that the deployment was finished.

    Log
 

Opening the Service Bus Sample Application

  1. In Oracle JDeveloper 12c, click the Applications tab, and select e2e-1201-servicebus.

    service bus app
  2. Expand Projects and ValidatePayment, and then double-click ValidatePayment.

    ValidatePayment
 

Running an Existing SOAP Service

In this section, you test the existing SOAP service.

  1. In the Proxy Services swimlane, right-click ValidatePS, and select Run.

    Run ValidatePS

    JDeveloper deploys the project to Integrated WebLogic Server. The deployment takes awhile if the server isn't running.

  2. On the Running: IntegratedWebLogicServer - Log tab, verify that the application is running.

    IntegratedWebLogicServer log tab
  3. On the Oracle Service Bus Console tab, enter the following values for the payload request, remove the other fields, and then click Execute:

    • CardNum = 1234123412341234
    • ExpireDate = 0316
    • AuthorizationAmount = 100
    Oracle Service Bus Console
  4. Verify that the response displays the status.

    Response

    The Response Document body displays the status of the request in Extensible Markup Language (XML) format. The status can be Authorized or Denied, and it's based on the requested authorization amount.

 

Exposing a SOAP Service as a REST Service

In this section, you expose the existing SOAP service as a REST service.

  1. In the Pipelines/Split-Joins swimlane, right-click ValidatePP, and select Expose As REST.

    Expose As REST

    The Create REST binding wizard is displayed.

  2. On the Create REST binding page, enter the following values for the REST service, and then click Edit an operation in the Operation Bindings pane:

    • Name: ValidateRS
    • Description RestService to validate payment
    Edit an operation
  3. On the REST Operation binding page, select the GET HTTP verb, and enter Validate Operation for the description.

    REST Operation Binding
  4. On the Request tab, select all fields except CardNum, ExpireDate, and AuthorizationAmount, and then click Delete parameter.

    Delete Parameters
  5. Select the CardNum parameter and rename it CardNumber.

    CardNumber change
  6. Click the Response tab, deselect XML, select JSON for Payload, and click OK.

    JSON Response
  7. Verify your work and click OK.

    Confirm REST Binding
 

Running a REST Service

In this section, you test the REST service.

  1. In the Proxy Services swimlane, right-click ValidateRS, and select Run.

    Run ValidateRS

    JDeveloper deploys the project to Integrated WebLogic Server. The deployment takes awhile if the server isn't running.

  2. On the Oracle Service Bus Console tab, enter or select the following values for the Request Document, and then click Execute:

    • Accept: application/json
    • CardNum: 1234123412341234
    • ExpireDate: 0316
    • AuthorizationAmount: 999.0
    Test ValidateRS
  3. Verify that the Response Document shows the status as Authorized.

    ValidateRS Response
  4. Enter or select the following values for the Request Document, and then click Execute:

    • Accept: application/json
    • CardNum: 1234123412341234
    • ExpireDate: 0316
    • AuthorizationAmount: 1000
    Test ValidateRS
  5. Verify that the Response Document shows the status as Denied.

    ValidateRS Response

    The Response Document body displays the status of the request in JSON format. The status can be Authorized or Denied, and it's based on the requested authorization amount.

 

Summary

Oracle Service Bus enables you to reuse the SOAP services that are in use today, and expose them as REST services to support mobile devices.

When you use REST-enabling in Oracle Service Bus, you can set the response format as XML and JSON, so that the mobile devices can consume data as needed.

In this tutorial, you learned to:

  • Test and execute a SOAP service by using the Oracle Service Bus Console
  • Expose a SOAP service as a REST service
  • Test and execute a REST service by using the Oracle Service Bus Console

Resources


Credits

  • Lead Curriculum Developer: Armando Hernandez
  • Other Contributors: Ronald Pinkerton, Mary Peek