cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Lambert (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CXF-5815) cxf not unmarshalling parent elements
Date Thu, 19 Jun 2014 22:48:24 GMT

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

Michael Lambert edited comment on CXF-5815 at 6/19/14 10:46 PM:
----------------------------------------------------------------

curl -v -X POST -d @post.json -H "Content-Type: application/vnd.healthmedia.user-data+json;version=1.0"
-H "Accept: applicationvnd.healthmedia.user-data+json;version=1.0"  http://localhost:8080/user-data-service/user-data

Sample payload (from file: post.json)
----
{
    "collectionDate": "2010-01-20T16:23:14.245-05:00",
    "createDate": "2008-09-20T16:23:14.245-04:00",
    "data": {
        "name": "WeightPounds",
        "value": 134
    },
    "dataSource": {
        "id": "453ba2"
    },
    "id": 13,
    "updateDate": "2008-11-20T16:23:14.245-05:00",
    "user": {
        "id": "0d8a7c33"
    }
}
----
In the above example neither id nor user.id will be populated when it enters the service (as
they are derived from a parent complexType) but data.name will be.


was (Author: macflecknoe):
curl -v -X POST -d @post.json -H "Content-Type: application/vnd.healthmedia.user-data+json;version=1.0"
-H "Accept: applicationvnd.healthmedia.user-data+json;version=1.0"  http://localhost:8080/user-data-service/user-data

Sample payload (from file: post.json):
{
    "collectionDate": "2010-01-20T16:23:14.245-05:00",
    "createDate": "2008-09-20T16:23:14.245-04:00",
    "data": {
        "name": "WeightPounds",
        "value": 134
    },
    "dataSource": {
        "id": "453ba2"
    },
    "id": 13,
    "updateDate": "2008-11-20T16:23:14.245-05:00",
    "user": {
        "id": "0d8a7c33"
    }
}

> cxf not unmarshalling parent elements
> -------------------------------------
>
>                 Key: CXF-5815
>                 URL: https://issues.apache.org/jira/browse/CXF-5815
>             Project: CXF
>          Issue Type: Bug
>          Components: JAXB Databinding
>    Affects Versions: 2.7.11
>         Environment: ubuntu 13.10, oracle java 1.7, tomcat 7.0
>            Reporter: Michael Lambert
>         Attachments: EntityType.java, UserDataType.java, beans.xml, common-v1.xsd, schema-0.0.1-SNAPSHOT-sources.jar,
schema-0.0.1-SNAPSHOT.jar, user-data-artifacts-0.0.1-SNAPSHOT-sources.jar, user-data-artifacts-0.0.1-SNAPSHOT.jar,
user-data-service-0.0.1-SNAPSHOT-sources.jar, user-data-service-0.0.1-SNAPSHOT.war, user-v1.xsd
>
>
> Base class elements are not being unmarshaled when passed into jax-rs service. For example
if I pass:
> {
>   "id": "12",
>   "name": "mike"
> }
> Where "id" comes from a base complexType:
> <xsd:complexType name="entityType" abstract="true">
> 		<xsd:sequence>
> 			<xsd:element name="id" type="tns:textType" minOccurs="0" maxOccurs="1" />
> 		</xsd:sequence>
> </xsd:complexType>
> and "name" comes from a complexType derived from the base type:
> <xsd:complexType name="userDataType">
> 		<xsd:complexContent>
> 			<xsd:extension base="common:entityType">
> 				<xsd:sequence>
> 					<xsd:element name="name" type="xsd:string" minOccurs="0" maxOccurs="1" />
> 				</xsd:sequence>
> 			</xsd:extension>
> 		</xsd:complexContent>
> </xsd:complexType>
> The service method does not receive the "id" value when the object is unmarshalled:
> @POST
> public void get(UserDataType user) {
>     assert user.getName() != null : "this passes";
>     assert user.getId() != null : "this fails";
> }
> The elements that belong to the derived class (and not the base class) are passed properly
(i.e. they are populated with data).
> This happens only when I unmarshall json objects. It works fine with XML.
> The project is on github (https://github.com/MacFlecknoe/service-repository-sample).
The schema with the parent "entityType" is located at https://github.com/MacFlecknoe/service-repository-sample/blob/master/schema/src/main/resources/schema/common/common-v1.xsd.
 The schema which contains the derived type is located at: https://github.com/MacFlecknoe/service-repository-sample/blob/master/schema/src/main/resources/schema/entity/user-v1.xsd.
The dto classes are generated in the project: https://github.com/MacFlecknoe/service-repository-sample/tree/master/user-data/artifacts.
And the service itself (including the cxf configuration which is in beans.xml) is located
here: https://github.com/MacFlecknoe/service-repository-sample/tree/master/user-data/service.
The marshaller is configured in https://github.com/MacFlecknoe/service-repository-sample/blob/master/user-data/service/src/main/webapp/WEB-INF/beans.xml.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message