Presentation is loading. Please wait.

Presentation is loading. Please wait.

Confidential – Oracle Internal/Restricted/Highly Restricted

Similar presentations


Presentation on theme: "Confidential – Oracle Internal/Restricted/Highly Restricted"— Presentation transcript:

1 Confidential – Oracle Internal/Restricted/Highly Restricted

2 Joe Greenwald Sr. Principal Instructor, Oracle University OOW 2018
Develop Database RESTful Web Services Using Oracle Java and PL/SQL Tools Joe Greenwald Sr. Principal Instructor, Oracle University OOW 2018 <Course name>

3 Program Agenda 1 What is a RESTFul web service and why do you want one? Implementation Challenges Implementation Choices Client access to RESTFul services Questions 2 3 4 5 Confidential – Oracle Internal/Restricted/Highly Restricted

4 Program Agenda 1 What is a RESTFul web service and why do you want one? Implementation Challenges Implementation Choices Client access to RESTFul services Questions 2 3 4 5 Confidential – Oracle Internal/Restricted/Highly Restricted

5 Understanding REST: You’re Already an Expert
Everyday you use a browser… …and you enter URLs to “GET” “resources.” Resources are linked together (hypermedia). Design a tree of resources with a single base resource. It is comparable to an object graph in Java or hierarchy of elements in an XML document. Resources are (usually) nouns or things. Each resource has a limited number of general-purpose operations that it may support (GET, PUT, POST, DELETE). A resource is uniquely identified by a URL. A collection is also a resource. A specific resource in a collection is located with its unique value. E.g. “roy” in this example: A URL comprises: a remote server … …a path …and a web page “resource” of a specific “media type.” Mobile Development on Oracle Cloud A - 5

6 Understanding REST: You’re Already an Expert
…and other “apps” that access remote servers, too. It’s not a human accessing the resource; it’s a browser (software)… Mobile devices have browsers too. It doesn’t have to be web page, it can be any file (media) type. Mobile Development on Oracle Cloud A - 6

7 Understanding REST: You’re Already an Expert
The HTTP protocol is used. There can be many request-response cycles. Request Response The client makes a request. The server responds. Mobile Development on Oracle Cloud A - 7

8 Understanding REST: The Four Slide Introduction
Resources HTTP verbs Status codes Media types GET GET GET GET GET Mobile Development on Oracle Cloud A - 8

9 Understanding REST: The Four Slide Introduction
Resources HTTP verbs Status codes Media types 'Read' a resource 'Create' a resource 'Update or Create' 'Delete' a resource 'Read' resource headers GET POST PUT DELETE HEAD Mobile Development on Oracle Cloud A - 9

10 Understanding REST: The Four Slide Introduction
Resources HTTP verbs Status codes Media types Informational Success Redirection Client Error Server Error 1xx 2xx 3xx 4xx 5xx Mobile Development on Oracle Cloud A - 10

11 Understanding REST: The Four Slide Introduction
Resources HTTP verbs Status codes Media types Payload type “requested” by client Via HTTP Parameter “accept” Defines MIME types; examples: application/json, application/xml, image/gif {"departments: [ {"id":"MAN","name":"Manfacturing"}, {"id":"HR","name":"Human Resources"}, {"id":"FIN","name":"Finance"}, ...etc... ]} Mobile Development on Oracle Cloud A - 11

12 JavaScript Object Notation (JSON): The Three Slide Introduction
JSON is a standard using human-readable text to transmit data objects of attribute-value pairs. It is typically used in machine-to-machine communications and is a contemporary replacement for the older XML standard. - Wikipedia { "firstName":"John", "lastName":"Smith", "isAlive":true, "age":25, "address": { "streetAddress":"21 2nd Street", "city":"New York", "state":"NY", "postalCode":" " }, "phoneNumbers": [ {"type":"home", "number":"1234"}, {"type":"office","number":"4567"} ], "children":[], "spouse":null } Mobile Development on Oracle Cloud A - 12

13 JavaScript Object Notation (JSON): The Three Slide Introduction
{ "firstName":"John", "lastName":"Smith", "isAlive":true, "age":25, "address": { "streetAddress":"21 2nd Street", "city":"New York", "state":"NY", "postalCode":" " }, "phoneNumbers": [ {"type":"home", "number":"1234"}, {"type":"office","number":"4567"} ], "children":[], "spouse":null } Textual data payloads Human readable Supports validation and schemas “Fat free” alternative to XML Compact mobile friendly payloads JavaScript has inbuilt support. Mobile Development on Oracle Cloud A - 13

14 JavaScript Object Notation (JSON): The Three Slide Introduction
Blocks delineated by ellipses Key-value pairs, separated by colon Key with quotes Strings and dates with quotes Boolean, integers, null without quotes Supports nesting of records Supports arrays/collections Empty array Null values Elements are comma delimited. { "firstName":"John", "lastName":"Smith", "isAlive":true, "age":25, "address": { "streetAddress":"21 2nd Street", "city":"New York", "state":"NY", "postalCode":" " }, "phoneNumbers": [ {"type":"home", "number":"1234"}, {"type":"office","number":"4567"} ], "children":[], "spouse":null } Mobile Development on Oracle Cloud A - 14

15 Why Support RESTFul Web Services?
REST has become the defacto standard for distributed processing on the web It’s easy All of Oracle Applications and products expose and/or consume RESTFul services All of Oracle’s development tools (Java, JavaScript, SQL-PL/SQL) support RESTFul services Registering REST resources with an application-specific resource version name (or number) to support versioning of REST resources. Declaring a default ADF REST framework version for REST resources allows service clients to utilize new features and enhancements at runtime, such as the advanced query capabilities offered in version 2 of the ADF REST runtime framework. By declaring a default framework version to process requests, REST application developers may opt into the features introduced by a specific ADF REST framework when they are ready. In JDeveloper release , framework versions 1, 2, and 3 exist. Specific runtime features of the ADF REST framework that support the exchange of resource information by client and server include: Interacting with the REST resource is supported by separate JSON-based media type structures for the resource, action execution, and the results of action execution. Passing a custom header to specify the version of the ADF REST runtime framework that will be used to process requests. The version header allows service clients to override the default version declaration defined by the REST application. In JDeveloper release , framework versions 1, 2, 3 exist. Interacting with the REST resource using standard HTTP request methods, including GET, POST, PATCH, and DELETE. Executing an HTTP method using an X-HTTP-Method-Override header on a POST request method when client restrictions prevent the use of standard HTTP methods to interact with the REST resource. Locating a REST resource item (such as a specific employee) or REST resource collection (such as an collection of all employees) is supported by REST-compliant URI path names based on resource names defined in the ADF Business Components Model project. Obtaining a description of the REST resource, including the resource attributes and available actions, is supported by a specific media type and describe action. Linking to a canonical REST resource is supported when a resource with a super set of updatable entities is defined. The canonical link supports alternate links for the backing view object. Filtering of the REST resource is supported by query string parameters on the URI specified by the client to access the specific resource. Encoding formats are supported on the REST resource to enable compression and decompression. Content streaming of BLOB and CLOB attributes exposed by the REST resource is supported by the ADF REST framework. Performing data consistency checks while invoking the RESTful web service is supported by the ADF REST framework. This capability uses version history in the database to enable clients to manage HTTP payloads according to updates in the resource itself. Authorizing users to access the REST resource is enabled by ADF Security permission grants. <Course name>

16 Program Agenda 1 What is a RESTFul web service and why do you want one? Implementation Challenges Implementation Choices Client access to RESTFul services Questions 2 3 4 5 Confidential – Oracle Internal/Restricted/Highly Restricted

17 Challenges Implementing RESTFul Web Services
Create and maintain code 80% is boilerplate – change impact analysis and effort to keep in synch with data sources 1 or 2 mappings to maintain: Code must be mapped to URI More complicated if persistence is involved (+ another mapping)

18 Implementation Supports Two Mappings
URI – Code Objects   Persistence Mechanism (Object Relational Mapping) @Stateless @Path("solar.customer") public class CustomerFacadeREST extends AbstractFacade<Customer> { @PersistenceContext(unitName = "REST_DB_DemoPU") private EntityManager em; public CustomerFacadeREST() { super(Customer.class); } @POST @Override @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) public void create(Customer entity) { super.create(entity); }

19 Program Agenda 1 What is a RESTFul web service and why do you want one? Implementation Challenges Implementation Choices Client access to RESTFul services Questions 2 3 4 5 Confidential – Oracle Internal/Restricted/Highly Restricted

20 Developing Data-based RESTFul Web Services with ADF Business Components (ADF BC)
ORM is based on metadata with graphical editors = Java “not required” Can script custom behaviors with Groovy or Java = easy to add custom behavior Built-in customizable validations Services present data and control transactions and security access Automatically synchronizes with underlying persistence layer Highly tunable

21 Oracle Application Development Framework (ADF)
View Controller Data Services Java EJB BAM ADF BC Web Services BPEL BI Database Apps Unlimited Legacy Bindings Data Controls Model Task Flows ADF Business Services In the introductory lesson, you learned that the ADF architecture includes a business services layer that handles data access, encapsulates business logic, and manages the object-relational mapping between Java objects and relational data. You also learned that business services can be implemented by using a variety of technologies, including Java classes, Enterprise JavaBeans (EJBs), ADF Business Components, web services, and many other types of services. In this lesson, you learn how to create a business services layer that uses ADF Business Components, and you learn how to generate data controls that you can use later to expose data in a user interface. Oracle Middleware 12c: Build Rich Client Applications with ADF

22 Types of ADF Business Components
Application Module View Objects Entity Objects OrdersForCust Customers MyService CustomerEO OrderEO ItemEO CustomersVO OrdersVO AllOrders When you use ADF BC to build the business services layer of your application, you work with three main types of components: entity objects, view objects, and application modules. These components provide a layer of abstraction between the application’s view of the data and the physical structure of the data source. Entity objects: Represent objects in the data source (usually tables, views, or synonyms in a database). Entity objects are the mechanism for persisting data to the database. Entity objects serve as an application cache for the data, they encapsulate business logic to enforce business rules, and they provide the object-relational mapping between the application and the database. At run time, an entity object represents a single row of data. Associations (indicated by black arrows in the Entity Objects section of the diagram) represent relationships between the objects (for example, foreign key relationships). View objects: Define an application-specific view of the data (usually based on SQL queries). View objects are the mechanism for reading data from the database. When end users modify data in the user interface, the view objects collaborate with entity objects to consistently validate and save the changes. At run time, a view object represents a collection of rows. View links (indicated by black arrows in the View Objects section of the diagram) define relationships (such as master-detail) between view object result sets. Oracle Middleware 12c: Build Rich Client Applications with ADF

23 ADF BC REST Web Service <Course name>

24 Implement RESTFUl Web Services with PL/SQL
BEGIN ORDS.define_service( p_module_name => 'testmodule1', p_base_path => 'testmodule1/', p_pattern => 'emp/', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_source => 'SELECT * FROM emp', p_items_per_page => 0); COMMIT; END; SQL Developer PL/SQL API APEX ORDS

25 Create PL/SQL REST Service
BEGIN ORDS.define_service( p_module_name => 'testmodule1', p_base_path => 'testmodule1/', p_pattern => 'emp/', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_source => 'SELECT * FROM emp', p_items_per_page => 0); COMMIT; END; Base ORDS URL : Schema (alias): Module : Template :

26 Oracle Application Express (APEX) Solution
About Oracle REST Data Services Oracle REST Data Services is a JEE-based alternative for Oracle HTTP Server (OHS) and mod_plsql. The JEE implementation offers increased functionality including command line based configuration, enhanced security, file caching and RESTful Web Services. Oracle REST Data Services also provides increased flexibility by supporting deployments using Oracle WebLogic Server, Oracle Glassfish Server, Apache Tomcat, and a standalone mode. The Oracle Application Express architecture requires some form of Web server to proxy requests between a Web browser and the Oracle Application Express engine. Oracle REST Data Services satisfies this need but its use goes beyond that of Oracle Application Express configurations. Using Oracle REST Data Services simplifies the deployment process because there is no Oracle home required as connectivity is provided using an embedded JDBC driver. See Oracle REST Data Services Installation, Configuration, and Development Guide for concepts and details. select * from customers where cust_id = :id <Course name>

27 What is Oracle REST Data Services (ORDS)?
ORDS is a Java application that enables developers with SQL and database skills to develop REST APIs for the Oracle Database, the Oracle Database 12c JSON Document store, and the Oracle NoSQL Database. Any application developer can use these APIs from any language environment, without installing and maintaining client drivers, in the same way they access other external services using the most widely used API technology: REST. ORDS is included with both Oracle Database and Oracle SQL Developer installs. It is supported in WebLogic, Tomcat, and as a standalone application running Jetty in embedded mode.

28 Install, Configure and Run ORDS
java -jar /u01/app/ords18/ords.war setup java -jar /u01/app/ords18/ords.war install java -jar /u01/app/ords18/ords.war

29 Enable ORDS for Schemas and Objects:
-- PLSQL Code to enable ORDS programmatically DECLARE BEGIN PRAGMA AUTONOMOUS_TRANSACTION; ORDS.ENABLE_OBJECT(p_enabled => TRUE, p_schema => 'SOADEMO', p_object => 'CUSTOMERS', p_object_type => 'TABLE', p_object_alias => 'customers', p_auto_rest_auth => TRUE); commit; END;

30 Create Module and Handler
Define Resource and Parameters Create Module and Handler Module and API Definition Define a Handler: Any valid SQL or PL/SQL block

31 Test

32 ORDS Functions – Define a Service in One Call
ORDS.define_service( p_module_name => ‘hrModule', p_base_path => ‘hr/', p_pattern => 'emp/', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_source => 'SELECT * FROM emp', p_items_per_page => 0); Module : A container for one or more templates, with an associated path (testmodule1/). Template : A container for one or more handlers. The template must be unique within the module and is associated with a specific path (emp/), which may or may not include parameters. Handler : A link to the actual work that is done. Typical handler methods include GET, POST, PUT, DELETE, which are passed in the HTTP header, rather than the URL. Each handler is associated with a specific source (or action), which can be of several types. Handler: SQL or PL/SQL <Course name>

33 ORDS Functions – Fully Manual Control
ORDS.define_module( p_module_name => ‘hrModule2', p_base_path => hr2/', p_items_per_page => 0); ORDS.define_template( p_module_name => hrModule2', p_pattern => 'emp/'); ORDS.define_handler( p_pattern => 'emp/', p_method => 'GET', p_source_type => ORDS.source_type_collection_feed, p_source => 'SELECT * FROM emp',

34 Program Agenda 1 What is a RESTFul web service and why do you want one? Implementation Challenges Implementation Choices Client access to RESTFul services Questions 2 3 4 5 Confidential – Oracle Internal/Restricted/Highly Restricted

35 Consume RESTFul Web Services in Clients
Java SE Java EE Web Browser cURL, Web Browser Plugins HTTP MAF

36 Demonstration Confidential – Oracle Internal/Restricted/Highly Restricted

37 Questions? joe.greenwald@oracle.com Joe Greenwald
Sr. Principal Instructor, Oracle Corporation

38 Experience Oracle University Learning Subscriptions. Visit education
Experience Oracle University Learning Subscriptions! Visit education.oracle.com/oowtrial Free Trial Subscription: Special invitation from Oracle University to attendees of Oracle OpenWorld or Code One Anytime, anywhere access Continually updated training on Oracle products and technologies. Experience the new Unlimited Product Learning Subscription Instructor notes Details: UPLS Trial: 1 subscription per attendee Ends December 21, 2018 or after attendee consumes 5 hours of learning on the trial subscription. Availability: Go to the education.oracle.com/oowtrial to activate your trial subscription. Oracle Confidential – Internal/Restricted/Highly Restricted

39 Are You Up For the Oracle University Zip Labs Challenge at Code One?
Join us in San Francisco, California at the Moscone West Center where you can compete to win a prize at the “Oracle University Zip Labs Challenge Booth.” When: Monday, October 22th – Open from 9:00am through 4:30pm Tuesday, October 23th – Open from 9:00am through 4:30pm Wednesday, October 24th – Open from 9:00am through 3:00pm What is the Oracle University Zip Labs Challenge? The Oracle University Zip Labs Challenge is a collection of labs, each minute long. Zip Labs guide you through a sequence of steps to accomplish a specific task within the Oracle Cloud Platform. It’s an opportunity to get started experiencing for yourself how some of Oracle’s new technologies work. You can select from labs in the categories covering: Virtual Machines: Creating a VM in OCI Autonomous Data Warehouse (ADW): Provisioning, Connecting to SQL, Machine Learning Autonomous Transaction Processing (ATP): Provisioning, Connecting to SQL, Scaling Great Learning. Great Technology. Great Prizes COME SEE WHAT ALL THE EXCITEMENT IS ABOUT AS YOU WORK THROUGH EXPERT DEVELOPED LABS AND CLIMB HIGHER ON OUR LEADERBOARD THROUGHOUT THE DAY – COMPETING WITH OTHER CONTESTANTS It’s simple to find us. Go to the 2nd floor of Moscone West.  As you complete labs and quizzes, you’ll earn points to boost your leaderboard standing.  At the end of each day, the top 5 winners win a fabulous prize.  So if you are up for the challenge – then we hope you drop by to showcase your skills and curiosity! Looking forward to seeing you there.  Confidential – Oracle Internal/Restricted/Highly Restricted

40 Your Chance to Influence Product Direction and Design!
The QR code is DYNAMIC so we can change where it points to if we want. Use the URL code-generator.com/manage/?aftercreate=1 Mary Beth has the account with her gmail. The Cloud Platform UX team would love to get your feedback on new designs. Sign up here:

41


Download ppt "Confidential – Oracle Internal/Restricted/Highly Restricted"

Similar presentations


Ads by Google