javaeetutorial
  1. javaeetutorial
  2. JAVAEETUTORIAL-131

Web Services | JAX-RS: Advanced Topics and Example | Runtime Content Negotiation is misleading and contains errors

    Details

      Description

      The section on "Runtime Content Negotiation" contains an example where the resource class level @Produces annotation sets a default MIME type of text/plain. The method getEmployeeAddressXml has a @Produces annotation which makes the method listen to requests asking for a text/xml MIME type.
      From my understanding, the subsequent sections make false statements:

      The getEmployeeAddressText method is called for an HTTP request that looks as follows:
      
      GET /employee
      content-type: text/plain
      500 Oracle Parkway, Redwood Shores, CA
      
      The getEmployeeAddressXml method is called for an HTTP request that looks as follows:
      
      GET /employee
      content-type: text/xml
      <address street="500 Oracle Parkway, Redwood Shores, CA" country="USA"/>
      

      First, it is at least misleading to have a GET request containing a message body. Worse though, from my understanding, it should be the "Accept" header content that will be matched against the @Produces annotation value. The "Content-type" header should be matched against the @Consumes annotation.

      If I should be wrong, the explanation of @Produces and @Consumes earlier in the chapter is very misleading.

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Ian Evans
            Reporter:
            kombatkuehn
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: