Hi
On 02/12/13 11:36, Jose María Zaragoza wrote:
Hello:

I'm using Apache CXF 2.7.3 and I've implemented a REST service by
JAX-RS API, with XML & JSON databinding support

I've enabled schema validation ( the same XSD file for both of them ),
and I use Jettison provider  (1.3.4) for JSON support

When I perform a XML request, all goes fine, but when I do the same
request in JSON format , I got the next message

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2:
Attribute 'name' is not allowed to appear in element 'field'.

The JSON payload sent is

{"requestType":{"client":{"application":"myapp","session":"000"},"event":{"code":3,"data":{"field":{"@name":"phone","$":"7774455"}}}}}


If I disabled  schema validation, and 'name' attribute is not mapped
to my JAXB object
is a Jettison's problem ?  is a CXF 2.7.3 problem ?

At XML level we have
<field name="phone">7774455</field>

I'm not sure Jettison can make a smarter decision than it already does, note '$' means it treats '7774455' as a mixed content.

Not sure why it is not mapped. I'll be working on the next Jettison release this month, will have a look at this issue

Sergey





Can I use another JSON provider with schema-validation ?



Schema declaration for <event> element is

<xs:complexType name="EventType">
<xs:sequence>
<xs:element name="code" type="xs:int" />
<xs:element name="data" type="tns:DataType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="DataType">
<xs:sequence>
<xs:element name="field" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
      <xs:extension base="xs:string">
         <xs:attribute name="name" type="xs:string">
        </xs:attribute>
      </xs:extension>
     </xs:simpleContent>
     </xs:complexType>
     </xs:element>
     </xs:sequence>
</xs:complexType>


Thanks and regards


Reply via email to