Disclaimer:  I don't have experience using Axis facilities for JSON.

There isn't a distinction between attributes and elements in JSON.
Essentially, every field is an attribute, but attributes may have complex
content.  So probably the JSON message should not use the '@' character to
distinguish an attribute.  Also, since order of fields is not significant
in JSON, XML schema concepts like <sequence> or "maxOccurs" may have no
fully corresponding JSON equivalent.

On Tue, Feb 18, 2025 at 7:40 AM robertlazarski <robertlazar...@gmail.com>
wrote:

> Could you please paste or attach your logs? That may help me understand
> the problem better. I don't have use cases combining XML and JSON in my own
> projects but I know the code pretty well and I can probably help.
>
> On Mon, Feb 17, 2025 at 5:23 AM Stefan Traud <stefan_tr...@yahoo.com>
> wrote:
>
>> Hi Robert
>> Using contract first with ADB, I continue to check feasibility to amend
>> our existing service with JSON support (based on XML Stream API with moshi).
>>
>> I'm currently struggling with xml types that include attributes. To
>> reproduce the issue I have amended the wsdl in the samples.quickstartadb to
>> include an attribute in the getPrice element:
>>
>> <xs:element name="getPrice">
>>
>>     <xs:complexType>
>>
>>         <xs:sequence>
>>             <xs:element name="symbol"
>>                 nillable="true" type="xs:string" />
>>
>>         </xs:sequence>
>>         <xs:attribute name="currency"
>>             type="xs:string" use="required"/>
>>
>>     </xs:complexType>
>>
>> </xs:element>
>>
>> My corresponding JSON message should then be something like:
>>
>> { "getPrice" : {"@currency": "USD", "symbol": "IBM" }}
>>
>> However the parse method in the GetPrice ADBBean keeps complaining "Required
>> attribute currency is missing"; specifically this call returns null:
>>
>> reader.getAttributeValue("http://quickstart.samples/xsd";, "currency");
>>
>> (However it works when using SOAP).
>>
>> Do I need to define attributes differently in the JSON message?
>>
>>
>>

Reply via email to