Avoid wrapping the object type name from input/output JSON (CXF Web Service)
cxf, json
Solution
If you are using maven, the JSONProvider class is here:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<version>2.7.5</version>
</dependency>
You might need another json provider properties to achieve your goals:
<jaxrs:providers>
<bean class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="dropRootElement" value="true"/>
<property name="dropCollectionWrapperElement" value="true"/>
<property name="serializeAsArray" value="true"/>
<property name="supportUnwrapped" value="true"/>
</bean>
</jaxrs:providers>
Problem
I have a CXF Web Service something like this: ``` @Service("MyWebService") public class MyWebService implements IMyWebService { @Autowired private IMyService MyService; public ResponseObject doSomething(RequestObject requestObject) { ResponseObject responseObject = new ResponseObject; . // do something.... . . return responseObject; } } ``` that expects an input JSON, say something like this: ``` { "requestObject" : { "amount" : 12.50, "userName" : "abcd123" } } ``` and produces an output JSON something like this: ``` { "responseObject" : { "success" : "true", "errorCode" : 0 } } ``` Is there a way to configure CXF such that it accepts the input JSON in the following format: ``` { "amount" : 12.50, "userName" : "abcd123" } ``` I need to strip out the object type name 'requestObject' / 'responseObject' in the input and output JSON. Is that even possible? Your help appreciated!