Oracle Fusion Middleware ?· 2.2 Defining the Root Resource Class ... For the Oracle Fusion Middleware…

Download Oracle Fusion Middleware ?· 2.2 Defining the Root Resource Class ... For the Oracle Fusion Middleware…

Post on 18-Aug-2018

212 views

Category:

Documents

0 download

Embed Size (px)

TRANSCRIPT

<ul><li><p>Oracle Fusion MiddlewareDeveloping and Securing RESTful Web Services for Oracle</p><p>WebLogic Server</p><p>12c (12.2.1.2.0)</p><p>E77984-02</p><p>February 2017</p><p>Documentation for software developers that describes how todevelop Java EE web services that conform to theRepresentational State Transfer (REST) architectural style usingJava API for RESTful Web Services (JAX-RS).</p></li><li><p>Oracle Fusion Middleware Developing and Securing RESTful Web Services for Oracle WebLogic Server, 12c(12.2.1.2.0)</p><p>E77984-02</p><p>Copyright 2013, 2016, Oracle and/or its affiliates. All rights reserved.</p><p>This software and related documentation are provided under a license agreement containing restrictions onuse and disclosure and are protected by intellectual property laws. Except as expressly permitted in yourlicense 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. Reverseengineering, disassembly, or decompilation of this software, unless required by law for interoperability, isprohibited.</p><p>The information contained herein is subject to change without notice and is not warranted to be error-free. Ifyou find any errors, please report them to us in writing.</p><p>If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it onbehalf of the U.S. Government, then the following notice is applicable:</p><p>U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are"commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of theprograms, including any operating system, integrated software, any programs installed on the hardware,and/or documentation, shall be subject to license terms and license restrictions applicable to the programs.No other rights are granted to the U.S. Government.</p><p>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 thatmay create a risk of personal injury. If you use this software or hardware in dangerous applications, then youshall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure itssafe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of thissoftware or hardware in dangerous applications.</p><p>Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks oftheir respective owners.</p><p>Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks areused under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron,the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced MicroDevices. UNIX is a registered trademark of The Open Group.</p><p>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 expresslydisclaim all warranties of any kind with respect to third-party content, products, and services unlessotherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliateswill not be responsible for any loss, costs, or damages incurred due to your access to or use of third-partycontent, products, or services, except as set forth in an applicable agreement between you and Oracle.</p></li><li><p>Contents</p><p>Preface ............................................................................................................................................................... vii</p><p>Documentation Accessibility .................................................................................................................... vii</p><p>Conventions................................................................................................................................................. vii</p><p>What's New in This Guide.......................................................................................................................... ix</p><p>New and Changed Features for Release 12c (12.2.1.x) ........................................................................... ix</p><p>New and Changed Features for Release 12c (12.2.1) .............................................................................. ix</p><p>New and Changed Features for Release 12c (12.1.3) ............................................................................... x</p><p>New and Changed Features for Release 12c (12.1.2) ............................................................................... x</p><p>1 Introduction to RESTful Web Services</p><p>1.1 Introduction to the REST Architectural Style ............................................................................... 1-1</p><p>1.2 What are RESTful Web Services? ................................................................................................... 1-2</p><p>1.3 Standards Supported for RESTful Web Service Development on WebLogic Server ............. 1-2</p><p>1.4 Roadmap for Implementing RESTful Web Services.................................................................... 1-3</p><p>1.5 Learn More About RESTful Web Services .................................................................................... 1-4</p><p>2 Developing RESTful Web Services</p><p>2.1 About RESTful Web Service Development................................................................................... 2-1</p><p>2.1.1 Summary of Tasks to Develop RESTful Web Services .................................................... 2-2</p><p>2.1.2 Example of a RESTful Web Service .................................................................................... 2-3</p><p>2.2 Defining the Root Resource Class .................................................................................................. 2-3</p><p>2.3 Defining the Relative URI of the Root Resource and Subresources.......................................... 2-4</p><p>2.3.1 How to Define the Relative URI of the Resource Class (@Path) .................................... 2-4</p><p>2.3.2 How to Define the Relative URI of Subresources (@Path) .............................................. 2-5</p><p>2.3.3 What Happens at Runtime: How the Base URI is Constructed ..................................... 2-5</p><p>2.4 Mapping Incoming HTTP Requests to Java Methods................................................................. 2-6</p><p>2.4.1 About the Jersey Bookmark Sample ................................................................................... 2-7</p><p>2.4.2 How to Transmit a Representation of the Resource (@GET) .......................................... 2-8</p><p>2.4.3 How to Create or Update the Representation of the Resource (@PUT) ........................ 2-9</p><p>2.4.4 How to Delete a Representation of the Resource (@DELETE) ..................................... 2-10</p><p>iii</p></li><li><p>2.4.5 How to Create, Update, or Perform an Action on a Representation of the Resource</p><p>(@POST)...................................................................................................................................... 2-10</p><p>2.5 Customizing Media Types for the Request and Response Messages ..................................... 2-11</p><p>2.5.1 How To Customize Media Types for the Request Message (@Consumes) ................ 2-11</p><p>2.5.2 How To Customize Media Types for the Response Message (@Produces)................ 2-122.5.3 What Happens At Runtime: How the Resource Method Is Selected for Response</p><p>Messages .................................................................................................................................... 2-12</p><p>2.6 Extracting Information From the Request Message .................................................................. 2-13</p><p>2.6.1 How to Extract Variable Information from the Request URI (@PathParam) ............. 2-13</p><p>2.6.2 How to Extract Request Parameters (@QueryParam).................................................... 2-14</p><p>2.6.3 How to Define the DefaultValue (@DefaultValue) ........................................................ 2-15</p><p>2.6.4 Enabling the Encoding Parameter Values (@Encoded) ................................................. 2-15</p><p>2.7 Building Custom Response Messages ......................................................................................... 2-16</p><p>2.8 Mapping HTTP Request and Response Entity Bodies Using Entity Providers .................... 2-18</p><p>2.9 Accessing the Application Context .............................................................................................. 2-20</p><p>2.10 Building URIs ................................................................................................................................ 2-20</p><p>2.11 Using Conditional GETs .............................................................................................................. 2-21</p><p>2.12 Accessing the WADL ................................................................................................................... 2-22</p><p>2.13 More Advanced RESTful Web Service Tasks ........................................................................... 2-23</p><p>3 Developing RESTful Web Service Clients</p><p>3.1 Summary of Tasks to Develop RESTful Web Service Clients .................................................... 3-1</p><p>3.2 Example of a RESTful Web Service Client .................................................................................... 3-2</p><p>3.3 Invoking a RESTful Web Service from a Standalone Client....................................................... 3-2</p><p>4 Building, Packaging, and Deploying RESTful Web Service Applications</p><p>4.1 Building RESTful Web Service Applications................................................................................ 4-1</p><p>4.2 Packaging RESTful Web Service Applications............................................................................. 4-1</p><p>4.2.1 Packaging With an Application Subclass .......................................................................... 4-2</p><p>4.2.2 Packaging With a Servlet...................................................................................................... 4-2</p><p>4.2.3 Packaging as a Default Resource ........................................................................................ 4-6</p><p>4.3 Deploying RESTful Web Service Applications ............................................................................ 4-7</p><p>5 Securing RESTful Web Services and Clients</p><p>5.1 About RESTful Web Service Security ............................................................................................ 5-1</p><p>5.2 Securing RESTful Web Services and Clients Using OWSM Policies ........................................ 5-1</p><p>5.3 Securing RESTful Web Services Using web.xml .......................................................................... 5-2</p><p>5.4 Securing RESTful Web Services Using SecurityContext............................................................. 5-3</p><p>5.5 Securing RESTful Web Services Using Java Security Annotations ........................................... 5-4</p><p>6 Testing RESTful Web Services........................................................................... 6-1</p><p>iv</p></li><li><p>7 Monitoring RESTful Web Services and Clients</p><p>7.1 About Monitoring RESTful Web Services..................................................................................... 7-17.2 Monitoring RESTful Web Services Using Enterprise Manager Fusion Middleware Control</p><p>................................................................................................................................................................ 7-2</p><p>7.3 Monitoring RESTful Web Services Using the Administration Console ................................... 7-2</p><p>7.4 Monitoring RESTful Web Services Using WLST ......................................................................... 7-3</p><p>7.5 Enabling the Tracing Feature .......................................................................................................... 7-6</p><p>7.6 Disabling RESTful Web Service Application Monitoring........................................................... 7-67.6.1 Disabling Monitoring for a RESTful Web Service Application Using Jersey</p><p>Property........................................................................................................................................ 7-77.6.2 Disabling Monitoring for a RESTful Web Service Application Using WebLogic</p><p>Configuration MBean................................................................................................................. 7-9</p><p>7.6.3 Disabling RESTful Web Service Application Monitoring for a WebLogic Domain.... 7-9</p><p>7.7 Enable Monitoring of Synthetic Jersey Resources in a RESTful Web Service Application.. 7-11</p><p>8 Using Server-Sent Events in WebLogic Server</p><p>8.1 Overview of Server-Sent Events (SSE)........................................................................................... 8-1</p><p>8.2 Understanding the WebLogic Server-Sent Events API............................................................... 8-1</p><p>8.3 Sample Applications for Server-Sent Events ................................................................................ 8-2</p><p>A Compatibility with Earlier Jersey/JAX-RS Releases</p><p>A.1 Develop RESTful Web Service Clients Using Jersey 1.18 (JAX-RS 1.1 RI) .............................. A-1</p><p>A.1.1 Example of a RESTful Web Service Client........................................................................ A-2</p><p>A.1.2 Creating and Configuring a Client Instance .................................................................... A-2</p><p>A.1.3 Creating a Web Resource Instance .................................................................................... A-4</p><p>A.1.4 Sending Requests to the Resource ..................................................................................... A-5</p><p>A.1.5 Receiving a Response from a Resource............................................................................. A-8</p><p>A.1.6 More Advanced RESTful Web Service Client Tasks....................................................... A-9</p><p>A.2 Support for Jersey 1.18 (JAX-RS 1.1 RI) Deployments Packaged with Pre-3.0 Servlets ...... A-10</p><p>v</p></li><li><p>vi</p></li><li><p>Preface</p><p>This preface describes the document accessibility features and conventions used in thisguide Developing and Securing RESTful Web Services for Oracle WebLogic Server.</p><p>Documentation AccessibilityFor information about Oracle's commitment to accessibility, visit the OracleAccessibility Program website at http://www.oracle.com/pls/topic/lookup?ctx=acc&amp;id...</p></li></ul>