https://issues.apache.org/jira/browse/CXF-5815
Thanks again Sergey On Thu, Jun 19, 2014 at 4:51 PM, Sergey Beryozkin <[email protected]> wrote: > Hi > > On 19/06/14 21:40, Lambert, Michael wrote: > >> Thanks Sergey but I dont think I was clear. The problem has nothing to do >> with xml attributes (my bad I should not have used the word 'attribute'). >> >> The problem is that the base class elements are not being unmarshalled. >> For >> example if I pass: >> >> { >> "id": "12", >> "name": "mike" >> } >> >> Can you please attach a generated Java bean (or several beans) to a new > JIRA issue and will test it tomorrow against the above sequence > > Cheers, Sergey > > > > 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 derived comlexType: >> >> <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> >> >> I am not receiving the "id" value in my JaxRS service when the object is >> unmarshaled: >> >> public void get(UserDataType user) { >> assert user.getName() != null : "this passes"; >> assert user.getId() != null : "this fails"; >> } >> >> This happens only with the base complexType elements when I unmarshall >> json >> objects. It works fine with XML. >> >> -Mike >> >> >> >> On Thu, Jun 19, 2014 at 4:20 PM, Sergey Beryozkin <[email protected]> >> wrote: >> >> 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 >>> >>> >> >
