0

I want to disable the CANONICALIZE_FIELD_NAMES feature and wanted to know how can I do that through xml http://cxf.apache.org/schemas/jaxrs.xsd. For example I would configure the providers as follows

<jaxrs:providers>
   <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
</jaxrs:providers>

I assume the features would also be configured in a similar fashion

<jaxrs:features>
   ----
</jaxrs:features>

I tried checking online did not find any solution

Abhijeet Kushe
  • 2,477
  • 3
  • 26
  • 39
  • Add an `ObjectMapper` bean and construct the `JacksonJsonProvider` with it. – Paul Samsotha Jul 01 '16 at 23:40
  • So it cannot be done through xml ? – Abhijeet Kushe Jul 03 '16 at 23:14
  • You _can_. Have a look at [this post](http://stackoverflow.com/a/31637849/2587435) – Paul Samsotha Jul 04 '16 at 01:28
  • Ok we cannot do it using .If not what is the use of this element ? – Abhijeet Kushe Jul 04 '16 at 22:43
  • What is it about that code I linked to that makes you think you cannot? – Paul Samsotha Jul 05 '16 at 00:43
  • No I asked the question because the example sets the feature as a property of the ObjectMapper and does not use element.So my original question was how can we add features using features element.I can obviously set the property on the ObjectMapper through Spring beans schema but since I am using the jaxrs xml schema I wanted to know how to do it using features.I hope this makes sense – Abhijeet Kushe Jul 05 '16 at 01:30
  • Just add the JSON provider into the feature list like you are currently doing? JAX-RS know nothing about ObjectMappers, so there is nothing you can configure in a JAX-RS way. You just need to add the configured ObjectMapper to the JSON provider, and register the provider with JAX-RS like you are currently doing. – Paul Samsotha Jul 05 '16 at 01:40
  • Or you can forget all this stuff, and use a ContextResolver instead (and configure the ObjectMapper programmatically). For that look at the link at the bottom of my answer in the same post. You can register the `ContextResolver` also as a JAX-RS provider. – Paul Samsotha Jul 05 '16 at 01:43
  • 1
    As far as the features XMl element, this is reserved for JAX-RS [`Feature`s](https://docs.oracle.com/javaee/7/api/javax/ws/rs/core/package-summary.html). You _could_ configure the JSON provider programmatically inside a `Feature`, and register it there. And then register the `Feature`. There's a few ways you can do this. – Paul Samsotha Jul 05 '16 at 01:44
  • Thanks more clear now – Abhijeet Kushe Jul 05 '16 at 02:51

0 Answers0