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

JAX-RS WebClient proxy sometimes fails to set Content-Type from @Consumes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5
    • 2.3.10, 2.4.7, 2.5.3, 2.6
    • JAX-RS
    • None
    • Talend Service Factory 2.5.0.0 (Karaf 2.2.4, CXF 2.5.0)

    • Unknown

    Description

      I have a JAX-RS interface called JobQueueEndpoint with a method like this:

      @POST
      @Path("job/

      {queue}

      ")
      @Consumes(MediaType.TEXT_XML)
      @Produces(

      {MediaType.TEXT_XML, MediaType.APPLICATION_JSON}

      )
      JobIdentifierDTO submitJob(@PathParam("queue") String queueName, String jobXml);

      I create a client for this API like so:

      JobQueueEndpoint resource = JAXRSClientFactory.create(jobQueueUrl, JobQueueEndpoint.class);

      and invoke:

      resource.submitJob("qFoo", "<job/>");

      But I get this:

      Jan 26, 2012 8:09:23 PM org.apache.cxf.jaxrs.utils.JAXRSUtils findTargetMethod
      WARNING: No operation matching request path "/jobqueue/job/qFoo" is found, Relative Path: /job/qFoo, HTTP Method: POST, ContentType: text/plain, Accept: text/xml,application/json,. Please enable FINE/TRACE log level for more details.

      The problem is that the client is sending "text/plain" and the server is expecting "text/xml". I'm guessing that's because the jobXml argument is a String. It seems to me that the client should always use the @Consumes value unless explicitly told otherwise. Perhaps the method should be refactored to take a Document instead of a String, but this problem seems like a bug.

      The other methods of this client work fine, so I believe it's not an environmental problem. I've tried to trace the code of WebClient, but I've gotten lost in its complexity...

      Attachments

        1. JaxRsExampleTest.java
          4 kB
          Chris Dolan

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            cdolan Chris Dolan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: