You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Sergey Beryozkin (Commented) (JIRA)" <ji...@apache.org> on 2012/01/27 10:28:41 UTC

[jira] [Commented] (CXF-4067) JAX-RS WebClient proxy sometimes fails to set Content-Type from @Consumes

    [ https://issues.apache.org/jira/browse/CXF-4067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13194575#comment-13194575 ] 

Sergey Beryozkin commented on CXF-4067:
---------------------------------------

Yes, I can see in the code it ignores Consumes in case of String, please try the workaround:
WebClient.client(proxy).header("Content-Type", "text/xml");
before the call
                
> JAX-RS WebClient proxy sometimes fails to set Content-Type from @Consumes
> -------------------------------------------------------------------------
>
>                 Key: CXF-4067
>                 URL: https://issues.apache.org/jira/browse/CXF-4067
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.5
>         Environment: Talend Service Factory 2.5.0.0 (Karaf 2.2.4, CXF 2.5.0)
>            Reporter: Chris Dolan
>         Attachments: JaxRsExampleTest.java
>
>
> 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...

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira