17 Working with Oracle Cloud Services

This chapter describes how to connect to and use Oracle Mobile Cloud Service to develop mobile services and mobile applications. It also describes how a mobile application can access data hosted on Oracle Java Cloud Service.

This chapter includes the following sections:

17.1 Introduction to Working with Oracle Cloud Services

You can use OEPE to work with Oracle Cloud services to develop and deploy groupings of APIs that are designed to support a specific set of applications.

17.2 Introduction to Working with MCS

Oracle Mobile Cloud Service enables you to develop and deploy groupings of APIs that are designed to support a specific set of applications. These APIs are available in the MCS mobile backend. You can develop mobile applications which you associate with the mobile backend to access those APIs.

Figure 17-1 illustrates the overall architecture of Oracle Mobile Cloud Service and how it works with mobile applications and enterprise services.

Figure 17-1 MCS Architecture

This image is described in the surrounding text

The mobile backend for MCS contains the platform APIs, custom APIs and connectors, including REST.

For more information about MCS, see http://cloud.oracle.com/mobile

17.2.1 Getting Started with MCS

OEPE allows you to create mobile applications that use services provided on an MCS backend.

Before you can sign in to an Oracle Cloud service, you must have a user account that defines your credentials (user name, password, and identity domain) and access rights to the service.

For information about requesting a trial subscription to an Oracle Cloud service, or purchasing a subscription to an Oracle Cloud service, see Getting Started with Oracle Cloud.

When an Oracle Cloud service is activated, Oracle sends the sign-in credentials and URL to the designated administrator. The administrator then creates an account for each user who needs access to the service. Check your email or contact your administrator for your account credentials and service URL.

Once you have a subscription to MCS, you create a connection to MCS following the instructions in "Integrating Oracle Cloud Services" in Oracle Enterprise Pack for Eclipse User's Guide.

17.2.1.1 Consuming MCS Services in MAF Applications

You can use mobile services created in MCS to build mobile apps.

In this case, the MCS APIs you will typically use include:

  • Tooling APIs for:

    • Asset Catalog (for APIs, API implementations, mobile backends, connectors)

    • Notifications

    • UI Tooling for Mobile API test invocation

    • User management for roles, user names, to use for testing the service

  • Collections APIs to access from custom code

  • System API for integrating notifications from the custom code

The steps you perform include the following:

  1. Search for the API you want to use.

  2. Implement the API:

    1. Download the scaffolding.

    2. Unzip and open the Javascript file in OEPE.

    3. Implement the endpoints in OEPE by editing methods in the Javascript file:

      Get the connectors available for the custom code to use.

      Get the notification API for integration within the custom code.

    4. Rezip the scaffolding and upload it to the implementations for the service.

  3. Test the API endpoints from the IDE by selecting the mobile backend and the backend version. Unless the API is set to allow unauthenticated access, you will have to use a user name and password.

17.2.1.2 Developing Mobile Clients for MCS Mobile Services

You can create mobile applications that use services provided on an MCS backend.

  • Tooling APIs for:

    • Asset Catalog (for APIs, policies, notifications)

    • Storage

    • UI Tooling for Mobile API test invocation

    • User management for roles, user names, to use for testing the service

  • Platform APIs for storage collection

  • Custom APIs for runtime URLs of the services defined in MCS by the customer

The steps you perform include the following:

  1. Authenticate with MCS.

  2. Download the Mobile Cloud Service SDK and start the project.

  3. Search for the mobile backend you want to use.

  4. Get the selected APIs for the mobile backend, including URL information and either a RAML or Swagger description.

  5. Get the storage collections for the mobile backend.

  6. Develop a Java client for REST API and the mobile client.

  7. Test the Java client in OEPE. Unless the API is set to allow unauthenticated access, you will have to use a user name and password

  8. Run and test the mobile client.

17.2.1.3 Using Mobile Backends

The resources for mobile applications including APIs are stored in a container called a mobile backend. Within the mobile backend you register the apps that can access the mobile backend and you select the PAIs that you want available for those apps.

You can have multiple backends, each serving a set of applications. In addition, you can have APIs that are used by multiple backends.

When an app accesses APIs through MCS, it is always in the context of a mobile backend. The app authenticates with the mobile backend credentials as well as with a user name and password (or an anonymous access key). If the called API includes calls to other APIs within the backend, the identity and credentials of the original caller are propagated through the chain of calls.

For more information about mobile backends, and using Oracle Mobile Cloud Service as a platform, see "Using Oracle Mobile Cloud Service" in Using Oracle Mobile Cloud Service

17.2.1.4 Importing a REST API

In order to work with a REST API you import a RAML definition from an MCS API. There are two ways that you can do this:

  • From a connection in Oracle Cloud view.

  • Using the REST Service Editor.

Before you begin:

You need to have a connection from OEPE to MCS in the Oracle Cloud view.

17.2.1.4.1 Importing a REST API from Oracle Cloud View

To import a definition:

  1. In the Oracle Cloud view, expand the connection and Oracle Cloud Service.

    To import a definition from API, expand that node to show the API node you want.

    To import a definition from MCS mobile backends, expand that node and choose the backend you want to show the API node, as shown in Figure 17-2.

    Figure 17-2 Importing a REST API

    This image is described in the surrounding text
  2. Right click and choose Import Definition.

    The Import Definition dialog opens.

  3. On the REST Service Description of the wizard, choose the parent folder where the REST Service Description file will be created, and enter a file name.

  4. On the Backend information page you choose the backend that is associated with the API. This page also shows whether Anonymous access is supported if basic authentication is enabled.

    If you have selected the API from the API node, choose the backend from the list of those associated with the API.

    If you chose the API from a specific backend then that backend is displayed and you cannot change it.

  5. The RAML Preview page of the wizard allows you to choose the options to use during import of the REST API. These include:

    • (Only when importing from API) The method to use if there are conflicts when you are importing a RAML definition to an existing REST Service description file.

      Merge: Use when the existing methods should be merged with new methods from RAML definition.

      Replace: Use when the new method should replace the existing methods.

      Create: Use when a new method should be created with new name in case of conflicts with existing methods.

    • The resources and methods to import. The wizard shows a tree created from the information in the RAML definition in the API. By default, all resources and methods are selected. Deselect those that you do not want to import.

    • You can launch the connection wizard if you want to edit the Base URI and store the information in connections.xml. The connection wizard will be opened when you click Finish.

      The connection wizard will be populated with data fetched from the MCS API, and the connection defined in the wizard is used to create the root path of the REST Service description.

17.2.1.4.2 Importing a REST API Using the REST Service Editor

You can import RAML definition from:

  • A Mobile Cloud Service backend's API. You must have a connection to Oracle Mobile Cloud Service.

  • A RAML file.

For more information about the REST Service Editor, see Section 16, "Working with REST Services."

To import a REST API:

  1. On the REST API tab of the REST Service Editor, click This image is described in the surrounding text to open the Import REST API or Data type dialog, shown in Figure 17-3.

    Figure 17-3 Importing RAML Definitions

    This image is described in the surrounding text
  2. Choose the source of the RAML definition: Mobile Backend, or RAML File.

  3. Click Next and complete the wizard.

    • Mobile Backend.

      On the Backend information page you choose the backend that is associated with the API. This page also shows whether Anonymous access is supported if basic authentication is enabled.

      If you have selected the API from the API node, choose the backend from the list of those associated with the API.

      If you chose the API from a specific backend then that backend is displayed and you cannot change it.

    • RAML File. Choose the file containing the RAML definition from the file system.

  4. The RAML Preview page of the wizard allows you to choose the options to use during import of the REST API. These include:

    • The method to use if there are conflicts when you are importing a RAML definition to an existing REST Service description file.

      Merge: Use when the existing methods should be merged with new methods from RAML definition.

      Replace: Use when the new method should replace the existing methods.

      Create: Use when a new method should be created with new name in case of conflicts with existing methods.

    • The resources and methods to import. The wizard shows a tree created from the information in the RAML definition in the API. By default, all resources and methods are selected. Deselect those that you do not want to import.

    • You can launch the connection wizard if you want to edit the Base URI and store the information in connections.xml. The connection wizard will be opened when you click Finish.

      The connection wizard will be populated with data fetched from the MCS API, and the connection defined in the wizard is used to create the root path of the REST Service description.

17.3 Enabling Mobile Applications to Access Data Hosted on Oracle Cloud

Mobile applications can access RESTful web services by creating a web service data control. Depending on the content type, mobile applications can access cloud data by dragging and dropping a data control into a MAF AMX user interface component, as described in Section 11.3.2, "How to Add UI Components and Data Controls to an MAF AMX Page," or programmatically, for applications whose content is delivered from a either a remote web server, or from locally stored HTML files.

17.3.1 How to Authenticate Against Oracle Cloud

You use the MAF Login Server Connection dialog to create a login server connection to authenticate against Oracle Cloud.

Before you begin:

Obtain the Oracle Cloud URL that is used for the login server connection.

To create a login URL with an Oracle Cloud endpoint:

  1. In the Project Explorer, expand the assembly project, then MAF and double-click MAF Application Editor.

  2. In the editor, select Security in the outline, and then click Create next to Default Login Server.

  3. Complete the General Options page of the Mobile Login Server Connection dialog, shown in Figure 17-4, by entering a name for the connection in the Connection Name field.

    Figure 17-4 Creating the Login to Oracle Cloud

    This image is described in the surrounding text
  4. Click Next. In the HTTP Basic Options page, enter the URL for Oracle Cloud in the Login URL field.

    Test the connection by clicking Test.

    For more information, refer to Section 29.6.2, "How to Designate the Login Page."

17.3.2 How to Create a Web Service Data Control to Access Oracle Java Cloud

The Create Data Service Control Wizard enables you to create the data control that accesses the hosted data. You use the WSDL URL of the web service deployed to Oracle Java Cloud to create this data control. If you do not know this URL, then you must create the URL to the WSDL document by appending the web service port name and ?wsdl to the application context root.

Before you begin:

You must have access to a web service application that has been deployed to Oracle Java Cloud Service. This application must be available through the Applications pane of the Oracle Java Cloud Service Control home page. In addition, its Status and State must be noted as both Up and Active, respectively, as illustrated by the HCMMobileService application shown in Figure 17-5.

Figure 17-5 The Java Cloud Services Control Home Page

This image is described in the surrounding text

To create a web service data control:

  1. Obtain the application context root of the web service hosted on Oracle Cloud as follows:

    1. Traverse to the application home page, shown in Figure 17-6, by clicking the application in the Applications pane (shown in Figure 17-5).

    2. Copy the URL, as shown in Figure 17-6. This URL is the application context root of the WSDL document.

      Figure 17-6 Copying the Web Service Application Context Root

      This image is described in the surrounding text
  2. Choose File > New > Other to open the New dialog.

  3. Expand Oracle > Mobile Application Framework and choose Data Control and click Next.

  4. In the New Data Control wizard, shown in Figure 17-7, choose the project, and then select Web Service as the Type.

    Figure 17-7 Creating a Data Control

    This image is described in the surrounding text
  5. Click This image is described in the surrounding text next to URL to open the Data Control Source dialog, as shown in Figure 17-8.

    Figure 17-8 Entering the URL for the WSDL Document

    This image is described in the surrounding text
  6. In the URL field, paste the URL of the web service that is deployed to (and currently running on) Oracle Cloud Java Service and click OK, and on the Data Control Source page, click Next.

  7. On the Data Control Details page of the wizard, set the id for the new data control, and click Next.

  8. On the Web Service Data Control page of the wizard, choose the services you want and click Next.

  9. Review the options you have chosen in the summary page of the wizard, then click Finish.

17.3.2.1 Configuring the Policy for Web Services

You must configure a policy for a web service that is secured on Oracle Cloud. Using the Edit Data Service Control Policies dialog, described at Section 15.3, "Accessing Secure Web Services," you can select the oracle/wss_http_token_over_ssl_client_policy. For descriptions of this (and other) policies, see "Determining Which Predefined Policies to Use" and "Predefined Policies" chapters in Oracle Fusion Middleware Securing Web Services and Managing Policies with Oracle Web Services Manager.

17.3.3 What Happens When You Deploy a Mobile Application that Accesses Oracle Java Cloud Service

After you deploy the application, the operations of the web service data control retrieve the data from a web service running on the Oracle Java Cloud Service instance.