Hi
Jettison only reports some of JSON properties as attributes if they have
a '@' prefix - I guess the reason it is done is because Jettison has no
type information but using '@' is obviously not portable.
Do you use the schema for XML as well ? If you only introduced it to
enable the validation of JSON payloads then change attributes to
elements or use BeanValidation.
Otherwise I can only suggest trying JacksonJaxbProvider, may be it can
do it.
I'm going to work on the next Jettison release soon enough, but I'm not
sure we can tackle this issue properly, perhaps I can introduce some
property which can be used to specify that specific properties are
attributes...
Cheers, Sergey
On 19/06/14 17:35, Lambert, Michael wrote:
I am having problems reading the attributes of objects that are generated
from an abstract schema. The attributes of the child class unmarshall
properly but those that exist in the base class dont show up at all.
The child class is defined as follows:
<xsd:complexType name="userDataType">
<xsd:annotation>
<xsd:documentation>Represents Key/Value Attribute assigned to a
User</xsd:documentation>
</xsd:annotation>
<xsd:complexContent>
<xsd:extension base="common:entityType">
<xsd:sequence>
<xsd:element name="collectionDate" type="xsd:dateTime" minOccurs="0"
maxOccurs="1" />
<xsd:element name="data" type="tns:dataType" minOccurs="0" maxOccurs="1" />
<xsd:element name="dataSource" type="dataSource:dataSourceType"
minOccurs="0" maxOccurs="1" />
<xsd:element name="user" type="tns:userType" minOccurs="0" maxOccurs="1" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
And its parent is defined:
<xsd:complexType name="entityType" abstract="true">
<xsd:sequence>
<xsd:element name="id" type="tns:textType" minOccurs="0" maxOccurs="1" />
<xsd:element name="link" type="atom:linkType" minOccurs="0" maxOccurs="1"
/>
<xsd:element name="createDate" type="xsd:dateTime" minOccurs="0"
maxOccurs="1" />
<xsd:element name="updateDate" type="xsd:dateTime" minOccurs="0"
maxOccurs="1" />
<xsd:element name="version" type="tns:positiveIntegerType" minOccurs="0"
maxOccurs="1" />
<xsd:element name="extension" type="tns:extensionType" minOccurs="0"
maxOccurs="1" />
</xsd:sequence>
<xsd:attributeGroup ref="tns:commonAttributes"/>
</xsd:complexType>
When I POST the following payload:
{
"collectionDate": "2010-01-20T10:07:46.629-05:00",
"createDate": "2008-09-20T10:07:46.629-04:00",
"data": {
"name": "WeightPounds",
"value": 134
},
"dataSource": {
"id": "453ba2"
},
"updateDate": "2008-11-20T10:07:46.629-05:00",
"user": {
"id": "0d8a7c33",
"firstName": "Mike"
},
"id": "1333333"
}
firstname and collectionDate are populated when it enters my service but
the ids are not. I simply dont get any attribute defined in the base
entityType.
Any idea why? The project is hosted here:
https://github.com/MacFlecknoe/service-repository-sample
The schema are located here:
https://github.com/MacFlecknoe/service-repository-sample/tree/master/schema/src/main/resources/schema/entity
and
https://github.com/MacFlecknoe/service-repository-sample/tree/master/schema/src/main/resources/schema/common
And my configuration for the JsonProvider is here:
https://github.com/MacFlecknoe/service-repository-sample/blob/master/user-data/service/src/main/webapp/WEB-INF/beans.xml
I really appreciate the help as we are in the last stages of development
and only just discovered this problem.
Thanks!
Mike
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com