Developing and Securing RESTful Web Services for Oracle ... Applications Building RESTful Web Service

  • View
    0

  • Download
    0

Embed Size (px)

Text of Developing and Securing RESTful Web Services for Oracle ... Applications Building RESTful Web...

  • Oracle® Fusion Middleware Developing and Securing RESTful Web Services for Oracle WebLogic Server

    14c (14.1.1.0.0) F18314-01 March 2020

  • Oracle Fusion Middleware Developing and Securing RESTful Web Services for Oracle WebLogic Server, 14c (14.1.1.0.0)

    F18314-01

    Copyright © 2007, 2020, Oracle and/or its affiliates.

    This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

    The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

    If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

    U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are "commercial computer software" or “commercial computer software documentation” pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.

    This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

    Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

    Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

    This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

  • Contents

    Preface Documentation Accessibility vii

    Conventions vii

    What’s New in This Guide New and Changed Features for Release 12c (12.2.1.x) viii

    New and Changed Features for Release 12c (12.2.1) viii

    New and Changed Features for Release 12c (12.1.3) ix

    1 Introduction to RESTful Web Services Introduction to the REST Architectural Style 1-1

    What are RESTful Web Services? 1-2

    Standards Supported for RESTful Web Service Development on WebLogic Server 1-2

    Roadmap for Implementing RESTful Web Services 1-3

    Learn More About RESTful Web Services 1-4

    2 Developing RESTful Web Services About RESTful Web Service Development 2-1

    Summary of Tasks to Develop RESTful Web Services 2-2

    Example of a RESTful Web Service 2-3

    Defining the Root Resource Class 2-3

    Defining the Relative URI of the Root Resource and Subresources 2-4

    How to Define the Relative URI of the Resource Class (@Path) 2-4

    How to Define the Relative URI of Subresources (@Path) 2-5

    What Happens at Runtime: How the Base URI is Constructed 2-5

    Mapping Incoming HTTP Requests to Java Methods 2-6

    About the Jersey Bookmark Sample 2-7

    How to Transmit a Representation of the Resource (@GET) 2-8

    How to Create or Update the Representation of the Resource (@PUT) 2-9

    How to Delete a Representation of the Resource (@DELETE) 2-10

    iii

  • How to Create, Update, or Perform an Action on a Representation of the Resource (@POST) 2-10

    Customizing Media Types for the Request and Response Messages 2-11

    How To Customize Media Types for the Request Message (@Consumes) 2-12

    How To Customize Media Types for the Response Message (@Produces) 2-12

    What Happens At Runtime: How the Resource Method Is Selected for Response Messages 2-13

    Extracting Information From the Request Message 2-13

    How to Extract Variable Information from the Request URI (@PathParam) 2-14

    How to Extract Request Parameters (@QueryParam) 2-15

    How to Define the DefaultValue (@DefaultValue) 2-15

    Enabling the Encoding Parameter Values (@Encoded) 2-16

    Building Custom Response Messages 2-16

    Mapping HTTP Request and Response Entity Bodies Using Entity Providers 2-19

    Accessing the Application Context 2-20

    Building URIs 2-21

    Using Conditional GETs 2-22

    Accessing the WADL 2-23

    More Advanced RESTful Web Service Tasks 2-23

    3 Developing RESTful Web Service Clients Summary of Tasks to Develop RESTful Web Service Clients 3-1

    Example of a RESTful Web Service Client 3-2

    Invoking a RESTful Web Service from a Standalone Client 3-2

    Using the Reactive JAX-RS Client API 3-3

    4 Building, Packaging, and Deploying RESTful Web Service Applications

    Building RESTful Web Service Applications 4-1

    Packaging RESTful Web Service Applications 4-1

    Packaging With an Application Subclass 4-2

    Packaging With a Servlet 4-2

    How to Package the RESTful Web Service Application with Servlet 3.0 4-3

    How to Package the RESTful Web Service Application with Pre-3.0 Servlets 4-5

    Packaging as a Default Resource 4-6

    Deploying RESTful Web Service Applications 4-7

    5 Securing RESTful Web Services and Clients About RESTful Web Service Security 5-1

    iv

  • Securing RESTful Web Services Using web.xml 5-1

    Securing RESTful Web Services Using SecurityContext 5-2

    Securing RESTful Web Services Using Java Security Annotations 5-3

    6 Testing RESTful Web Services

    7 Monitoring RESTful Web Services and Clients About Monitoring RESTful Web Services 7-1

    Monitoring RESTful Web Services Using the Administration Console 7-2

    Monitoring RESTful Web Services Using WLST 7-2

    Enabling the Tracing Feature 7-5

    Disabling RESTful Web Service Application Monitoring 7-6

    Disabling Monitoring for a RESTful Web Service Application Using Jersey Property 7-7

    Disabling Monitoring for a RESTful Web Service Application Using WebLogic Configuration MBean 7-8

    Disabling RESTful Web Service Application Monitoring for a WebLogic Domain 7-9

    Enable Monitoring of Synthetic Jersey Resources in a RESTful Web Service Application 7-10

    8 Using Server-Sent Events in WebLogic Server Overview of Server-Sent Events (SSE) 8-1

    Using Server-Sent Events 8-1

    Understanding the WebLogic Server-Sent Events API 8-2

    Sample Applications for Server-Sent Events 8-2

    A Compatibility with Earlier Jersey/JAX-RS Releases Develop RESTful Web Service Clients Using Jersey 1.18 (JAX-RS 1.1 RI) A-1

    Example of a RESTful Web Service Client A-2

    Creating and Configuring a Client Instance A-2

    Creating a Web Resource Instance A-4

    Sending Requests to the Resource A-5

    How to Build Requests A-5

    How to Send HTTP Requests A-6

    How to Pass Query Parameters A-7

    How to Configure the Accept Header A-7

    How to Add a Custom Header A-8

    How to Configure the Request Entity A-8

    v

  • Receiving a Response from a Resource A-9

    How to Access the Status of Request A-9

    How to Get the Response Entity A-9

    More Advanced RESTful Web Service Client Tasks A-9

    Support for Jersey 1.18 (JAX-RS 1.1 RI) Deployments Packaged with Pre-3.0 Servlets A-10

    vi

  • Preface

    This preface describes the document access