Oracle   发布时间:2022-05-17  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Oracle APEX 5.1发布 RESTful Web Service教程大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。


Before You Begin

Purpose

This tutorial covers creating a RESTful Web Service and accessing the Web Service through an application in Application Express 5.1. It also covers consuming the Web Service using a REST clIEnt.

Time to Complete

Approximately 40 minutes.

OvervIEw

Web Services enable applications to interact with one another over the web in a platform-neutral,language independent environment. In a typical Web Services scenario,a business application sends a request to a service at a given URL by using the protocol over http. The service receives the request,processes it,and returns a response. Web Services are typically based on Simple Object Access Protocol (SOAP) or Representational State Transfer (REST) architectures. RESTful Web Services are result orIEnted. The scope of the Web Service is found in the URI and the method of the service is described by the http method that is used such as GET,POST,PUT,and DELETE.

The RESTful Web Service Wizard is a set of pages in the sql Workshop area of Oracle Application Express that help you to create a RESTful Web Service declaratively. Once you have defined a RESTful Web Service,you can call it with a unique Uniform Resource IDentifIEr (URI). RESTful Web Services are organized within Oracle APEX through a hIErarchy of a module,a resource template and handlers within a template. The resource template includes a prefix for the URI,which is completed with a final portion of the URI defined by the handler.

This tutorial covers creating a RESTful Web Service declaratively using Oracle Application Express's sql Workshop tool,and then consuming the same service by creating an application and adding a Web Service Reference to the RESTful Web Service. The RESTful Web Service is also consumed using a REST clIEnt.

Please keep in mind the following while running this tutorial:

  • Logging into your Oracle Application Express workspace:Your Oracle Application Express workspace may resIDe in an on-premises Oracle Database or in Oracle Database Cloud Services. The login credentials differ depending on where your workspace is located:
    • Logging into Oracle Application Express in a Oracle Database Cloud Service: Go to the Oracle Help Center for Cloud,and select Platform and Infrastructure. From here,select your Database Cloud Service and the Get Started page will appear.
    • Logging in to Oracle Application Express on-premises: From your browser,go to the location of your on-premises installation of your Oracle Application Express workspace provIDed by your Workspace administrator.
  • Application ID:Screenshots in this tutorial show a blurred Application ID. Your Application ID can be any value assigned automatically while creating the application.
  • Schema:If you are accessing an Oracle Application Express workspace in Database Schema Service,you have one schema assigned to you with a schema name that you cannot change. If you are accessing the workspace in an on-premises Oracle database,you may have more than one schema assigned to your workspace by the Oracle Application Express Instance administrator.

What Do You Need?

Before starting this tutorial,you should:

  • Have access to an Oracle Database 11.2.x.x or later release,including Enterprise Edition and Express Edition (Oracle Database XE),either on-premises or in a Database Cloud Service.
  • Install Oracle Application Express Release 5.1 into your Oracle Database with RESTful Services configured in Oracle Application Express (for on-premises only).
  • Download and unzip thefiles.zipinto your working directory.
  • ExecuteCreate_Employees.sqlfrom the extracted files,to create required database objects.

Creating a RESTful Web Service

In this topic,you create a RESTful Web Service using RESTful Services tool in sql Workshop. The RESTful Web Service Wizard is a set of pages in sql Workshop that help you to create a new RESTful Web Service declaratively. The RESTful Web Service calls a specific sql statement in your database.

Creating a RESTful Web Service with GET and PUT Resource Handlers

To create a RESTful Web Service on the Employees table with sample GET and PUT service handlers,perform the below steps:

  1. From the Oracle Application Express Home page,select thesql Workshoptab and selectRESTful Services.

    Description of this image
  2. From the RESTful Services page,select theCreate a New RESTful Serviceoption.

    Description of this image
  3. A page loads with entrIEs grouped under three different categorIEs named RESTful Services Module,Resource Template,and Resource Handler. Under RESTful Services Module,enteremployeesfor name,and scroll down further.

    Description of this image
  4. Under Resource Template,enteremployees/for URI Template to IDentify your Uniform Resource IDentifIEr (URI),and scroll down further.

    Description of this image
  5. Under Resource Handler,selectGETfor Method,queryfor Source Type,CSVfor Format. This IDentifIEs the http method to be used for the Resource Handler.
    Enter the following sql query for Source,and clickCreate Module.

    select * from employees

    Description of this image
  6. The GET Handler is created under employees/. To edit its propertIEs,clickGETunder employees/.

    Description of this image
  7. SelectNofor Requires Secure Access,and clickApply Changes.

    Description of this image
  8. To test the behavior of the RESTful Service Handler,clickTest.

    Note:If your screen does not show a Test button,please ensure that RESTful Services are configured in your Oracle Application Express installation properly.

    Description of this image
  9. You are prompted to save the file which you can then vIEw using a CSV editor.

    Description of this image
  10. The CSV format result set is displayed.

    Description of this image
  11. Let us Now create a Handler for the POST method in the same Web Service. ClickCreate Handlerunder employees/.

    Description of this image
  12. SelectPOSTfor Method andPL/sqlfor Source Type. Enterapplication/Jsonfor MIME Types Allowed. SelectNofor Requires Secure Access. Enter the following PL/sql code for Source,and clickCreate.

    declare
    ID employees.employee_ID%TYPE;
    begin
    ID := employees_seq.nextval;

    insert into employees
    (employee_ID,first_name,last_name,email,hire_date,job_ID)
    values
    (ID,:first_name,:last_name,:email,to_date(:hire_date,'DD-MM-YYYY'),
    :job_ID);

    :employee_ID := ID;
    end;

    Description of this image
  13. Scroll down the page,and clickCreate Parameterto add an OUT parameter to the handler that will return the newly created employee’s ID.

    Description of this image
  14. Enteremployee_IDfor name and Bind Variable name. SelectOUTfor Access Method,http headerfor Source Type,Stringfor Parameter Type,and clickCreate.

    Description of this image
  15. The OUT parameter is created.

    Description of this image
  16. ClickCreate Parameteragain to add the following IN parameters to the handler.

    @H_165_502@
    name Bind Variable name Access Method Parameter Type
    first_name
    first_name IN
    String@H_753_419@
    email
    email
    IN
    String
    last_name last_name IN String
    hire_date
    hire_date IN
    String
    job_ID
    job_ID IN
    String
    Description of this image

    In the next section,you create a new template to retrIEve JsON result set based on query One Row with a bind variable.

Creating a Resource Handler with Query One Row

In this section,you will create a RESTful Service that provides detailed information of an employee,given the employee id. The result is returned in JSON format. Perform the following steps:

  1. ClickCreate Template.

    Description of this image
  2. Enteremployees/{ID}for URI Template,and clickCreate.

    Description of this image
  3. ClickCreate Handlerunder employees/{ID}.

    Description of this image
  4. SelectGETfor Method,query One Rowfor Source Type,andNofor Requires Secure Access.
    Enter the following sql query for Source,and clickCreate.

    select * from employees where employee_ID = :ID

    Description of this image
  5. Scroll down and clickCreate Parameter.

    Description of this image
  6. EnterIDfor name and Bind Variable name. SelectINfor Access Method,and clickCreate.

    Description of this image
  7. You want to change the Source Type. Under Parameters,click theIDlink under name.

    Description of this image
  8. SelectURIfor Source Type,and clickApply Changes.

    Description of this image
  9. Before testing this handler,you have to set a bind variable to pass a value for the input parameter(ID). ClickSet Bind Variables >.

    Description of this image
  10. Enter103for :ID,and clickTest.

    Description of this image
  11. Complete details of the employee with employee_ID = 103 is displayed.

    Description of this image
Creating a Resource Handler with Employees Feed

In this section,you will be creating a RESTful service of a feed source type. The feed results are rendered in JSON format. Each item in the feed contains a summary of a resource and a hyperlink to a full representation of the resource. Perform the below steps:

  1. ClickCreate Template.

    Description of this image
  2. EnteremployeesFeed/for URI Template,and clickCreate.

    Description of this image
  3. Under employeesFeed/,clickCreate Handler.

    Description of this image
  4. SelectGETfor Method,Feedfor Source Type,andNofor Requires Secure Access. Under Source,enter the following sql query,and clickCreate.

    select employee_ID,first_name
    from employees
    order by employee_ID,first_name

    Description of this image
  5. UnderemployeesFeed/,clickGETto open the Resource Handler Editor.

    Test.

    Description of this image
  6. The results are rendered in JsON format. Each item consists of a URI which contains the base URI from this RESTful Service,and the value of employee_ID used as the parameter. For the Feed source type,the first column must be a unique IDentifIEr. It will be transformed into a hyperlink when this RESTful Service is called.
    In this example,employee_ID is the first column and will turn into a hyperlink.

    For example,in the screenshot shown below,the URI for an employee withemployee_ID = 100ishttps://:<hostname>:<port>/ords/hr/employeesFeed/100

    Note:The URI shown in this example is specific to the database On-Premise subscription used for executing this tutorial,and it might be different for you. The value of the URI also depends on whether you are performing this tutorial On-Premises or on a Cloud Service. In general,the URI formats are as follows:

    @H_165_502@
    On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<employee_ID>

    For example:http://localhost:9090/ords/hr/employeesFeed/100
    where ords is set up on port9090during Oracle APEX installation,hris the schema name,employeesFeedis the Resource Template name,and100is the employee_ID.
    On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<employee_ID>

    For example:https://databasetrial:<user>.db.us2.oraclecloudapps.com/hr/employeesFeed/100
    where<user>.db.us2.oraclecloudapps.com/hr/is the Service URL for the cloud service subscription,and100is the employee_ID.
    Description of this image
  7. Select the URI for one of the employee_IDs,and copy it to clipboard.

    Description of this image
  8. Open a browser,paste the copIEd URI,and press Enter. Notice that the details of that particular employee are returned as a JsON result set.

    Description of this image
Creating a Resource Handler with Employees Feed for a Given Department

In this section,you will be creating a RESTful service of a feed source type given the Department ID. The feed results are rendered as JSON. Perform the below steps:

  1. ClickCreate Template.

    Description of this image
  2. EnteremployeesFeed/{ID},and clickCreate.

    Description of this image
  3. Under employeesFeed/{ID},clickCreate Handler.

    Description of this image
  4. SelectGetfor Method,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615; Font-style: italic;">select employee_ID,first_name
    from employees
    where department_ID = :ID

    Description of this image
  5. Scroll down further,and clickCreate Parameter >to add an IN parameter to the handler that will receive the department_ID.

    Create.

    idlink under Name.

    Description of this image
  6. SelectURIfor Source Type,and clickApply Changes.

    Description of this image
  7. Before testing this handler,you have to set bind variable to pass a value for the input parameter,ID. ClickSet Bind Variables >.

    Description of this image
  8. Enter60for :ID,and clickTest.

    Description of this image
  9. The results are rendered in JsON format. Each item consists of a URI which contains the base URI from this RESTful Service,and the value of department_ID used as the parameter. For the Feed source type,the first column must be unique IDentifIEr and will be transformed into a hyperlink when this RESTful Service is called.
    In this example,department_IDis the first column and will turn into a hyperlink.

    For example,the URI for an employee with department_ID = 60 ishttp://<hostname>:<port>/ords/hr/employeesFeed/60?page=1where page=1 indicates that these results are part of page 1. If there are many records in the result set,the results can span across page 2 and so on.

    Note:The URI shown in this example is specific to the database On-Premise service subscription used for executing this tutorial,the URI formats are as follows:

    @H_165_502@
    On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<department_ID>?page=1

    For example:http://localhost:9090/ords/hr/employeesFeed/60?page=1
    where ords is set up on port9090during Oracle APEX installation,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615;">hris the schema name,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615;">employeesFeedis the Resource Template name and60is the department_ID.
    On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<department_ID>?page=1

    For example:https://databasetrial:<user>.db.us2.oraclecloudapps.com/hr/employeesFeed/60?page=1
    where<user>.db.us2.oraclecloudapps.com/hr
    /is the Service URL for the cloud service subscription,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615;">employeesFeedis the Resource Template name,and60is the department_ID.
    Description of this image
Creating a RESTful Web Service Reference in Oracle Application Express

In this topic,you consume the RESTful Web Service in Oracle Application Express by creating a database application and by creating a Web Service Reference in the application. You create a form and report page that uses the web service.

Note:If you are executing this tutorial On-Premises,make sure you have granted the connect privileges by executing theAPEX_ACL.sqlscript from thefiles.zipfolder that you had downloaded and unzipped in the Prerequisites section of this tutorial.

  1. From the Oracle Application Express home page,click the down arrow next to App Builder,and selectDatabase Applications.

    Description of this image
  2. Click theCreate icon.

    Description of this image
  3. Accept the default,and clickNext >.

    Description of this image
  4. EnterRESTful Web Services Demofor name,and clickNext >.

    Description of this image
  5. ClickNext >.

    Next >.

    Description of this image
  6. SelectApplication Express Accountsfor Authentication Scheme,and clickNext >.

    Description of this image
  7. ClickCreate Application.

    Description of this image
  8. The application is created. ClickShared Components.

    Description of this image
  9. Under Data References,clickWeb Service References.

    Description of this image
  10. ClickCreate >.

    Oracle APEX 5.1发布 RESTful Web Service教程

    " style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_11.png">
    Description of this image
  11. SelectRESTfor What type of Web reference would you like to create,and clickNext >.

    Description of this image
  12. Enteremployeesfor name. SelectGETfor http Method andNofor Basic Authentication. For the URL,enter the Web Reference URI for the GET Service Handler which was created in the first section of this tutorial.

    As explained in the below table,your URI depends on the location of your Oracle Application Express instance,whether On-Premises or on a Database Cloud Service.

    @H_853_1419@ On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/

    For example:http://localhost:9090/ords/hr/employees/
    where ords is set up on port9090during Oracle APEX installation,hris the schema name,employeesis the Resource Template name. On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/

    For example:<user>.db.us2.oraclecloudapps.com/hr/employees/
    wherehttps: databasetrial:<user>.db.us2.oraclecloudapps.com/hr/is the Service URL for the cloud service subscription andemployeesis the Resource Template name. This RESTful Web Service does not require an http header parameter. So,scroll down and click theDelete headericon.


    Description of this image
  13. ClickNext >.

    Description of this image
  14. There are no parameters defined for the GET Service HandIEr. So,click theDelete Parametericon for input Parameters.

    Description of this image
  15. ClickNext >.

    Description of this image
  16. Now,you have to define the REST Outputs. SelectTextfor Output Format.Entercommafor Parameter Delimiter,and\nfor New Record Delimiter.
    Under Output Parameters,enterEmployee IDfor nameand1for Path. SelectStringfor Type,and clickAdd Parameter.

    Description of this image
  17. Similarly,add the following Output Parameters,and clickCreate.

    name Path Type
    name
    2
    String
    Hire Date
    6
    String
    Job ID
    7
    String
    Description of this image
  18. Click theVIEw Reporticon.

    Description of this image
  19. Click theTesticon for employees.

    Description of this image
  20. Employees' details is displayed in the Response section. ClickCancel.

    Description of this image
  21. ClickApplication<n>in the breadcrumb.

    img alt="Clicking Application in the breadcrumb." src="http://img.code.cc/vcimg/static/loading.png" class="ScreenShot collapsible-outline" Title="Clicking Application

    in the breadcrumb." style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_23.png">

    Description of this image
  22. ClickCreate Page >.

    Oracle APEX 5.1发布 RESTful Web Service教程

    ." style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_24.png">
    Description of this image
  23. Click theFormicon.

    Description of this image
  24. Click theReport and Formon Web Service icon.

    Description of this image
  25. Selectemployeesfor Web Service Reference,doRESTfor Operation,and clickNext >.

    Note:Employees appears in the select List for Web Service Reference because you added it under Web Service References in Shared Components.

    Description of this image
  26. ClickNext >.

    Description of this image
  27. ClickNext >.

    Description of this image
  28. Select all four parameters,that is,employee ID,name,Hire Date,andJob ID. ClickNext >.

    Description of this image
  29. Accept the default an clickNext >.

    Description of this image
  30. ClickCreate.

    Description of this image
  31. The new page is created. ClickSave and Run Page.

    Description of this image
  32. Enter your Oracle Application Express credentials,and clickLog In.

    Description of this image
  33. Clicksubmit.

    Description of this image
  34. The Web Service is executed,and the results displayed.

    Description of this image
Consuming the RESTful Web Service Created in Oracle Application Express Using a REST Client

In this section,you consume the Web Service that you have created in Oracle Application Express,using a REST Client.

Note:For the purpose of this tutorial,we will be using the RESTClient add-on in Firefox to demonstrate how to consume the RESTful Web Service created in APEX. You can also use other REST Clients such as,REST Easy and RESTer to perform these steps in Firefox. If you are using Google Chrome,you can install add-ons such as Postman to perform the steps.

  1. Open Firefox and install theRESTClient,a debugger for RESTful web servicesadd-on to your browser.

    Description of this image
  2. Open the installed add-on in your browser.

    Description of this image
  3. To fetch the details of an employee,selectGETas the Request Method. For the URL,whether On-Premises or on a Database Cloud Service. In this example,<hostname>:<port>/ords/hr/employees/employeesis the URL used for theOn-Premise machine.

    @H_853_1419@ On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<Resource Handler>

    For example:http://localhost:9090/ords/hr/employees/employees
    where ords is set up on port9090during Oracle APEX installation,employeesis the Resource Template name andemployeesis the Resource Handler. On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<Resource Handler>

    For example:<user>.db.us2.oraclecloudapps.com/hr/employees/
    employeeswherehttps: databasetrial:<user>.db.us2.oraclecloudapps.com/hr/is the Service URL for the cloud service subscription andemployeesis the Resource Template name andemployeesis the Resource Handler.

    ClickSEND.

    Description of this image
  4. Select theResponse Body (PrevIEw)tab to vIEw all the employee records.

    Description of this image
  5. To insert new values into the employees table,under headers,selectCustom header.

    Description of this image
  6. EnterContent-Typeas name,application/Jsonas Value,and clickOK.

    Description of this image
  7. In the RESTClIEnt page,enterPOSTas the request method,enter the same URL as that of the GET method,enter the following code in the Request Body,and clickSEND.

    {
    "first_name":"Supriya",
    "last_name":"Ananth",
    "email":"SUPANANT",
    "hire_date":"13-05-2001",
    "job_ID":"AD_PRES"
    }
    Description of this image
  8. Under Response,selectResponses header. You see that the new employee's information is added into the Employees table. The newly created employee’s ID is returned back to the application.

    Summary

    In this tutorial,you have learned how to:

    • Create a RESTful Web Service with various Resource Handlers using Oracle Application Express.
    • Create a RESTful Web Service Reference in Application Express.
    • Consume the Web Service created in Application Express using a REST client.

Before You Begin

Purpose

This tutorial covers creating a RESTful Web Service and accessing the Web Service through an application in Application Express 5.1. It also covers consuming the Web Service using a REST client.

Time to Complete

Approximately 40 minutes.

The RESTful Web Service Wizard is a set of pages in the SQL Workshop area of Oracle Application Express that help you to create a RESTful Web Service declaratively. Once you have defined a RESTful Web Service,and then consuming the same service by creating an application and adding a Web Service Reference to the RESTful Web Service. The RESTful Web Service is also consumed using a REST client.

Please keep in mind the following while running this tutorial:

  • Logging into your Oracle Application Express workspace:Your Oracle Application Express workspace may reside in an on-premises Oracle Database or in Oracle Database Cloud Services. The login credentials differ depending on where your workspace is located:
    • Logging into Oracle Application Express in a Oracle Database Cloud Service: Go to the Oracle Help Center for Cloud,select your Database Cloud Service and the Get Started page will appear.
    • Logging in to Oracle Application Express on-premises: From your browser,go to the location of your on-premises installation of your Oracle Application Express workspace provided by your Workspace Administrator.
  • Application ID:Screenshots in this tutorial show a blurred Application ID. Your Application ID can be any value assigned automatically while creating the application.
  • Schema:If you are accessing an Oracle Application Express workspace in Database Schema Service,you may have more than one schema assigned to your workspace by the Oracle Application Express Instance Administrator.

What Do You Need?

Before starting this tutorial,you should:

  • Have access to an Oracle Database 11.2.x.x or later release,either on-premises or in a Database Cloud Service.
  • Install Oracle Application Express Release 5.1 into your Oracle Database with RESTful Services configured in Oracle Application Express (for on-premises only).
  • Download and unzip thefiles.zipinto your working directory.
  • Execute

    Creating a RESTful Web Service

    In this topic,you create a RESTful Web Service using RESTful Services tool in sql Workshop. The RESTful Web Service Wizard is a set of pages in sql Workshop that help you to create a new RESTful Web Service declaratively. The RESTful Web Service calls a specific sql statement in your database.

    Creating a RESTful Web Service with GET and PUT Resource Handlers

    To create a RESTful Web Service on the Employees table with sample GET and PUT service handlers,perform the below steps:

    1. From the Oracle Application Express Home page,select thesql Workshoptab and selectRESTful Services.

      Description of this image
    2. From the RESTful Services page,select theCreate a New RESTful Serviceoption.

      Description of this image
    3. A page loads with entrIEs grouped under three different categorIEs named RESTful Services Module,and scroll down further.

      Description of this image
    4. Under Resource Template,and scroll down further.

      Description of this image
    5. Under Resource Handler,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615; Font-style: italic;">select * from employees

      Description of this image
    6. The GET Handler is created under employees/. To edit its propertIEs,clickGETunder employees/.

      Description of this image
    7. SelectNofor Requires Secure Access,and clickApply Changes.

      Description of this image
    8. To test the behavior of the RESTful Service Handler,please ensure that RESTful Services are configured in your Oracle Application Express installation properly.

      Description of this image
    9. You are prompted to save the file which you can then vIEw using a CSV editor.

      Description of this image
    10. The CSV format result set is displayed.

      Description of this image
    11. Let us Now create a Handler for the POST method in the same Web Service. ClickCreate Handlerunder employees/.

      Description of this image
    12. SelectPOSTfor Method andPL/sqlfor Source Type. Enterapplication/Jsonfor MIME Types Allowed. SelectNofor Requires Secure Access. Enter the following PL/sql code for Source,
      :job_ID);

      :employee_ID := ID;
      end;

      Description of this image
    13. Scroll down the page,and clickCreate Parameterto add an OUT parameter to the handler that will return the newly created employee’s ID.

      Description of this image
    14. Enteremployee_IDfor name and Bind Variable name. SelectOUTfor Access Method,and clickCreate.

      Description of this image
    15. The OUT parameter is created.

      Description of this image
    16. ClickCreate Parameteragain to add the following IN parameters to the handler.

      @H_165_502@
      name Bind Variable name Access Method Parameter Type
      first_name
      first_name IN
      String@H_753_419@
      email
      email
      IN
      String
      last_name last_name IN String
      hire_date
      hire_date IN
      String
      job_ID
      job_ID IN
      String
      Description of this image

      In the next section,you create a new template to retrIEve JsON result set based on query One Row with a bind variable.

    Creating a Resource Handler with Query One Row

    In this section,given the employee id. The result is returned in JSON format. Perform the following steps:

    1. ClickCreate Template.

      Description of this image
    2. Enteremployees/{ID}for URI Template,and clickCreate.

      Description of this image
    3. ClickCreate Handlerunder employees/{ID}.

      Description of this image
    4. SelectGETfor Method,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615; Font-style: italic;">select * from employees where employee_ID = :ID

      Description of this image
    5. Scroll down and clickCreate Parameter.

      Description of this image
    6. EnterIDfor name and Bind Variable name. SelectINfor Access Method,and clickCreate.

      Description of this image
    7. You want to change the Source Type. Under Parameters,click theIDlink under name.

      Description of this image
    8. SelectURIfor Source Type,and clickApply Changes.

      Description of this image
    9. Before testing this handler,you have to set a bind variable to pass a value for the input parameter(ID). ClickSet Bind Variables >.

      Description of this image
    10. Enter103for :ID,and clickTest.

      Description of this image
    11. Complete details of the employee with employee_ID = 103 is displayed.

      Description of this image
    Creating a Resource Handler with Employees Feed

    In this section,you will be creating a RESTful service of a feed source type. The feed results are rendered in JSON format. Each item in the feed contains a summary of a resource and a hyperlink to a full representation of the resource. Perform the below steps:

    1. ClickCreate Template.

      Description of this image
    2. EnteremployeesFeed/for URI Template,and clickCreate.

      Description of this image
    3. Under employeesFeed/,clickCreate Handler.

      Description of this image
    4. SelectGETfor Method,first_name

      Description of this image
    5. UnderGETto open the Resource Handler Editor.

      Test.

      Description of this image
    6. The results are rendered in JsON format. Each item consists of a URI which contains the base URI from this RESTful Service,the URI formats are as follows:

      Description of this image
    7. Select the URI for one of the employee_IDs,and copy it to clipboard.

      Description of this image
    8. Open a browser,and press Enter. Notice that the details of that particular employee are returned as a JsON result set.

      Description of this image
    9. Creating a Resource Handler with Employees Feed for a Given Department

      In this section,you will be creating a RESTful service of a feed source type given the Department ID. The feed results are rendered as JSON. Perform the below steps:

      1. ClickCreate Template.

        Description of this image
      2. EnteremployeesFeed/{ID},and clickCreate.

        Description of this image
      3. Under employeesFeed/{ID},clickCreate Handler.

        Description of this image
      4. SelectGetfor Method,first_name
        from employees
        where department_ID = :ID

        Description of this image
      5. Scroll down further,and clickCreate Parameter >to add an IN parameter to the handler that will receive the department_ID.

        Create.

        idlink under Name.

        Description of this image
      6. SelectURIfor Source Type,and clickApply Changes.

        Description of this image
      7. Before testing this handler,ID. ClickSet Bind Variables >.

        Description of this image
      8. Enter60for :ID,and clickTest.

        Description of this image
      9. The results are rendered in JsON format. Each item consists of a URI which contains the base URI from this RESTful Service,the URI formats are as follows:

      On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<employee_ID>

      For example:100is the employee_ID. @H_165_502@
      On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<employee_ID>

      For example:100is the employee_ID.
      @H_165_502@
      On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<department_ID>?page=1

      For example:60is the department_ID.
      On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<department_ID>?page=1

      For example:60is the department_ID.
      Description of this image
Creating a RESTful Web Service Reference in Oracle Application Express

In this topic,you consume the RESTful Web Service in Oracle Application Express by creating a database application and by creating a Web Service Reference in the application. You create a form and report page that uses the web service.

Note:If you are executing this tutorial On-Premises,147); text-decoration-line: none;" rel="nofollow">files.zip

folder that you had downloaded and unzipped in the Prerequisites section of this tutorial.

  1. From the Oracle Application Express home page,and selectDatabase Applications.

    Description of this image
  2. Click theCreate icon.

    Description of this image
  3. Accept the default,and clickNext >.

    Description of this image
  4. EnterRESTful Web Services Demofor name,and clickNext >.

    Description of this image
  5. ClickNext >.

    Next >.

    Description of this image
  6. SelectApplication Express Accountsfor Authentication Scheme,and clickNext >.

    Description of this image
  7. ClickCreate Application.

    Description of this image
  8. The application is created. ClickShared Components.

    Description of this image
  9. Under Data References,clickWeb Service References.

    Description of this image
  10. ClickCreate >.

    Oracle APEX 5.1发布 RESTful Web Service教程

    " style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_11.png">
    Description of this image
  11. SelectRESTfor What type of Web reference would you like to create,and clickNext >.

    Description of this image
  12. Enteremployeesfor name. SelectGETfor http Method andNofor Basic Authentication. For the URL,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615;">

    @H_853_1419@ On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/

    For example:employeesis the Resource Template name. On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/

    For example:https: databasetrial:<user>.db.us2.oraclecloudapps.com/hr/is the Service URL for the cloud service subscription andemployeesis the Resource Template name. This RESTful Web Service does not require an http header parameter. So,scroll down and click theDelete headericon.


    Description of this image
  13. ClickNext >.

    Description of this image
  14. There are no parameters defined for the GET Service HandIEr. So,click theDelete Parametericon for input Parameters.

    Description of this image
  15. ClickNext >.

    Description of this image
  16. Now,and clickAdd Parameter.

    Description of this image
  17. Similarly,and clickCreate.

    name Path Type
    name
    2
    String
    Hire Date
    6
    String
    Job ID
    7
    String
    Description of this image
  18. Click theVIEw Reporticon.

    Description of this image
  19. Click theTesticon for employees.

    Description of this image
  20. Employees' details is displayed in the Response section. ClickCancel.

    Description of this image
  21. ClickApplication<n>in the breadcrumb.

    img alt="Clicking Application in the breadcrumb." src="http://img.code.cc/vcimg/static/loading.png" class="ScreenShot collapsible-outline" Title="Clicking Application

    in the breadcrumb." style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_23.png">

    Description of this image
  22. ClickCreate Page >.

    Oracle APEX 5.1发布 RESTful Web Service教程

    ." style="Box-sizing: border-Box; Font-size: 14.0238px; border: 1px solID gray; vertical-align: mIDdle; max-wIDth: 100%; height: auto; padding: 4px; wIDth: auto; display: block;" src="http://pic.sunansheng.com/csdn/74025246/creating_REST_02_24.png">
    Description of this image
  23. Click theFormicon.

    Description of this image
  24. Click theReport and Formon Web Service icon.

    Description of this image
  25. Selectemployeesfor Web Service Reference,and clickNext >.

    Note:Employees appears in the select List for Web Service Reference because you added it under Web Service References in Shared Components.

    Description of this image
  26. ClickNext >.

    Description of this image
  27. ClickNext >.

    Description of this image
  28. Select all four parameters,andJob ID. ClickNext >.

    Description of this image
  29. Accept the default an clickNext >.

    Description of this image
  30. ClickCreate.

    Description of this image
  31. The new page is created. ClickSave and Run Page.

    Description of this image
  32. Enter your Oracle Application Express credentials,and clickLog In.

    Description of this image
  33. Clicksubmit.

    Description of this image
  34. The Web Service is executed,and the results displayed.

    Description of this image
Consuming the RESTful Web Service Created in Oracle Application Express Using a REST Client

In this section,using a REST Client.

Note:For the purpose of this tutorial,you can install add-ons such as Postman to perform the steps.

  1. Open Firefox and install theRESTClient,a debugger for RESTful web servicesadd-on to your browser.

    Description of this image
  2. Open the installed add-on in your browser.

    Description of this image
  3. To fetch the details of an employee,serif; padding: 3px; background-color: transparent; border-radius: 4px; line-height: 1.615;"><hostname>:<port>/ords/hr/employees/employeesis the URL used for theOn-Premise machine.

    @H_853_1419@ On-Premises http://localhost:<Port where ords is set up>/ords/<schema name>/<Resource Template name>/<Resource Handler>

    For example:employeesis the Resource Template name andemployeesis the Resource Handler. On a Cloud Service <Service URL as received in the Welcome email from Oracle Cloud>/<Resource Template name>/<Resource Handler>

    For example:https: databasetrial:<user>.db.us2.oraclecloudapps.com/hr/is the Service URL for the cloud service subscription andemployeesis the Resource Template name andemployeesis the Resource Handler.

    ClickSEND.

    Description of this image
  4. Select theResponse Body (PrevIEw)tab to vIEw all the employee records.

    Description of this image
  5. To insert new values into the employees table,selectCustom header.

    Description of this image
  6. EnterContent-Typeas name,and clickOK.

    Description of this image
  7. In the RESTClIEnt page,
    "job_ID":"AD_PRES"
    }

    Description of this image
  8. Under Response,selectResponses header. You see that the new employee's information is added into the Employees table. The newly created employee’s ID is returned back to the application.

    Summary

    In this tutorial,you have learned how to:

    • Create a RESTful Web Service with varIoUs Resource Handlers using Oracle Application Express.
    • Create a RESTful Web Service Reference in Application Express.
    • Consume the Web Service created in Application Express using a REST clIEnt.
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
编程之家官方1群(满)
编程之家官方2群(满)
编程之家官方3群(满)
编程之家官方4群
编程之家官方5群(新)
  • 上一篇:【Oracle Database 12c的新特性】下一篇:Logdump Reference for Oracle Gol

Oracle相关文章

Oracle导入导出命令
只导某些表:
Oracle递归查询
SQL: select * from PT_ORG_INFO START WITH id=&#39;102&#39; CONNECT BY PRIOR id=par_id 连表递归查询SQL: sel
DG:重启之后主备数据重新同步
问题描述:本来配置好的DG第二天重启之后,发现主备库数据不能同步,在主库上执行日志切换以及创建表操作都传不到备库上,造成这种错误的原因是主库实例断掉后造成备库日志与主库无法实时接收 主库:orcl 备
delete误删数据使用SCN恢复
参考51CTO博客 问题描述:使用scn号恢复误删数据 1.查询系统闪回的scn值以及当前日志的scn值,因为我这个是测试,创建的表是在在后边,所以scn值要大于下边这两个scn值,所以对我恢复数据没
ORA-00845 startup启动不起来关于磁盘空间扩充
问题描述:今天在虚拟机下进行startup的操作,但是没有起来,系统报错:ORA-00845: MEMORY_TARGET not supported on this system 1.startup
oracle实例状态
oracle数据库实例启动过程分三个步骤,分别是启动实例,加载数据库,打开数据。 1.NOMOUNT模式:这种模式只会创建实例,不会打开任何的数据文件,用户要以sysdba的身份登录,才具有关闭和启动
startup启动不起来关于监听的问题
问题描述:要在sqlplus中启动到startup状态,但是提示我没有监听,本来以为启动一下就可以,但是connecting to一直卡半天,stop都停止不了 1.发现监听有问题,前去更改 SQL&
DG:switchover切换操作
问题描述:我们配置DG的目的就是为了在主库出现故障时,备库能够提供服务,保证业务的正常运行,switchover是用户有计划的进行停机切换,能够保证不丢失数据,我记录一下我进行switchover中的
MySQLMsSQLOracleSqlitePostgre SQLMariadbMongoDBNoSQLHBaseJDBCmycat
  • • Oracle导入导出命令
  • • Oracle递归查询
  • • Oracle创建用户、表空间并设置
  • • DG:重启之后主备数据重新同步
  • • delete误删数据使用SCN恢复
  • • oracle逻辑存储结构
  • • ORA-00845 startup启动不起来关
  • • oracle实例状态
  • • 基于SCN增量恢复DG同步
  • • startup启动不起来关于监听的问
  • • DG:switchover切换操作
  • • RHEL5.6静默安装oracle11.2.0数

Oracle APEX 5.1发布 RESTful Web Service教程

微信公众号搜 "程序精选"关注
  • • Oracle导入导出命令
  • • Oracle递归查询
  • • Oracle创建用户、表空间并设置
  • • DG:重启之后主备数据重新同步
  • • delete误删数据使用SCN恢复
  • • oracle逻辑存储结构
  • • ORA-00845 startup启动不起来关
  • • oracle实例状态
  • • 基于SCN增量恢复DG同步
  • • startup启动不起来关于监听的问
python-3.xpandasswiftarraysspring-boosql-serverrubydataframeamazon-webfirebasegoalgorithmazuredelphiVBAregexPowerShellasp.net-coelasticseaspring-mvcruby-on-ramultithrealoopsgoogle-clovisual-stutomcatperformancapache-spaasp.net-mvTSQLgoogle-clounity3d.net-corevb.netfor-loopmavenmachine-leauthenticaherokuscaladjango-modpysparklinqobjective-if-statemesshasynchronodplyrwinformssecurityjpaentity-frauser-intergraphqlfirebase-roptimizatidebuggingdjango-vievariablesgoogle-bigmatlabparsingamazon-ec2xamarinnetworkingsql-serverrecursionintellij-iintegercmakeentity-fraimage-procfirebase-asqlalchemydata-strucindexingspring-datautomationplsqlnlp

大佬总结

以上是大佬教程为你收集整理的Oracle APEX 5.1发布 RESTful Web Service教程全部内容,希望文章能够帮你解决Oracle APEX 5.1发布 RESTful Web Service教程所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: