cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <j...@apache.org>
Subject [jira] [Resolved] (CXF-6103) Nillable field, in a json payload, was sent as "@nil":"true" instead of an empty string
Date Fri, 14 Nov 2014 17:50:34 GMT

     [ https://issues.apache.org/jira/browse/CXF-6103?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sergey Beryozkin resolved CXF-6103.
-----------------------------------
    Resolution: Not a Problem
      Assignee: Sergey Beryozkin

> Nillable field, in a json payload, was sent as "@nil":"true" instead of an empty string
> ---------------------------------------------------------------------------------------
>
>                 Key: CXF-6103
>                 URL: https://issues.apache.org/jira/browse/CXF-6103
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 2.7.13
>         Environment: Windows Seven, Linux Red Hat Enterprise 6
>            Reporter: Michele Milesi
>            Assignee: Sergey Beryozkin
>         Attachments: cxf-6103-test-case.tar.gz
>
>
> Moving from CXF version 2.2.7 to 2.7.13 a nillable field, in a jax-rs client with json
format, wil be sent with the annotation "@nil":"true" instead of an empty string (as configured).
> The request with the version 2.7.13
> {noformat}
> ---------------------------
> ID: 1
> Address: http://localhost:8080/test/test/echo
> Http-Method: POST
> Content-Type: application/json
> Headers: {Accept=[application/json], Content-Type=[application/json]}
> Payload: {"nillableField":{"@nil":"true"}}
> --------------------------------------
> {noformat}
> The request with the version 2.7.7
> {noformat}
> ---------------------------
> ID: 1
> Address: http://localhost:8080/test/test/echo
> Http-Method: POST
> Content-Type: application/json
> Headers: {Accept=[application/json], Content-Type=[application/json]}
> Payload: {"nillableField":""}
> --------------------------------------
> {noformat}
> *The client configuration*
> {code:xml}
> <bean id="simpleConverter" class="org.codehaus.jettison.mapped.SimpleConverter" />
> <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
>     <property name="dropRootElement" value="true" />
>     <property name="ignoreNamespaces" value="true" />
>     <property name="typeConverter" ref="simpleConverter" />
>     <property name="supportUnwrapped" value="true" />
>     <property name="writeXsiType" value="false" />
>     <property name="serializeAsArray" value="true" />
>     <property name="dropCollectionWrapperElement" value="false" />
>     <property name="convention" value="mapped" />
> </bean>
> <jaxrs:client id="testServiceClient" address="http://localhost:8080/test/"     serviceClass="it.icteam.test.cxf.service.TestService">
>     <jaxrs:headers>
>         <entry key="Accept" value="application/json" />
>     </jaxrs:headers>
>     <jaxrs:providers>
>         <ref bean="jsonProvider" />
>     </jaxrs:providers>
>     <jaxrs:features>
>         <core:logging />
>     </jaxrs:features>
> </jaxrs:client>
> {code}
> *The request Pojo*
> {code:java}
> package it.icteam.test.cxf.model;
> import javax.xml.bind.annotation.XmlAccessType;
> import javax.xml.bind.annotation.XmlAccessorType;
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlRootElement;
> /**
>  * @author m.milesi
>  */
> @XmlRootElement
> @XmlAccessorType(XmlAccessType.FIELD)
> public class TestRequest {
> 	@XmlElement(required = true)
> 	private String mandatoryField;
> 	
> 	@XmlElement(required = false)
> 	private String optionalField;
> 	
> 	@XmlElement(required = true, nillable=true)
> 	private String nillableField;
> 	/**
> 	 * @return the mandatoryField
> 	 */
> 	public String getMandatoryField() {
> 		return mandatoryField;
> 	}
> 	/**
> 	 * @param mandatoryField the mandatoryField to set
> 	 */
> 	public void setMandatoryField(String mandatoryField) {
> 		this.mandatoryField = mandatoryField;
> 	}
> 	/**
> 	 * @return the optionalField
> 	 */
> 	public String getOptionalField() {
> 		return optionalField;
> 	}
> 	/**
> 	 * @param optionalField the optionalField to set
> 	 */
> 	public void setOptionalField(String optionalField) {
> 		this.optionalField = optionalField;
> 	}
> 	/**
> 	 * @return the nillableField
> 	 */
> 	public String getNillableField() {
> 		return nillableField;
> 	}
> 	/**
> 	 * @param nillableField the nillableField to set
> 	 */
> 	public void setNillableField(String nillableField) {
> 		this.nillableField = nillableField;
> 	}
> }
> {code}
> *The service interface*
> {code:java}
> package it.icteam.test.cxf.service;
> import javax.ws.rs.Consumes;
> import javax.ws.rs.POST;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> import it.icteam.test.cxf.model.TestRequest;
> import it.icteam.test.cxf.model.TestResponse;
> @Path("/test")
> @Consumes({ "application/json" })
> @Produces({ "application/json" })
> public interface TestService {
> 	@Path("echo")
> 	@POST
> 	TestResponse echo(TestRequest request);
> }
> {code}
> *The maven dependencies*
> {code:xml}
> <properties>
>     <!-- cxf.version>2.7.7</cxf.version-->
>     <cxf.version>2.7.13</cxf.version>
>     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>     <maven.compiler.source>1.7</maven.compiler.source>
>     <maven.compiler.target>1.7</maven.compiler.target>
> </properties>
> <dependencies>
>     <dependency>
>         <groupId>org.apache.cxf</groupId>
> 	<artifactId>cxf-bundle</artifactId>
> 	<version>${cxf.version}</version>
>     </dependency>
>     <dependency>
>         <groupId>org.apache.cxf</groupId>
>         <artifactId>cxf-rt-rs-extension-providers</artifactId>
>         <version>${cxf.version}</version>
>     </dependency>
>     <dependency>
>         <groupId>org.codehaus.jettison</groupId>
>         <artifactId>jettison</artifactId>
>         <version>1.3.6</version>
>     </dependency>
>  </dependencies>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message