Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-3760

Problematic inheritance of @Produces/@Consumes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.2
    • 2.3.7, 2.4.3, 2.5
    • JAX-RS
    • None
    • Unknown

    Description

      Given the sample interface invoiceWebservice:

       
      @Path("invoice/")
      @Consumes(MediaType.APPLICATION_XML)
      @Produces(MediaType.APPLICATION_XML)
      public interface InvoiceWebservice {
      	@POST
      	public void insert(WSInvoice wsInvoice);
      
      	[...]
      }
      

      The usage of insert of this sample interface will cause an error, if used as both client and server interface.

      The client will send the http header "Accept: text/plain" due to return type void of insert(WSInvoice). But the server will respond with http "406 not acceptable", because the method inherited @Produces(MediaType.APPLICATION_XML).

      A workaround is to only annotate the methods, so insert does not get an @Produces annotation, or adding "text/plain" to @Consumes.

      Attachments

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            marco.schulte Marco Schulte
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: