Thanks for your feedback. Since xml attributes do not have a correspondance in 
json, I would expect that there are conventions on how to handle these.For 
example, when experimenting with mapped JSON, the generated soap message is 
properly populated with attributes from the json string when using the "@" 
prefix (this is using libraries from jettison). Unfortunately I do not know the 
convention for xml attributes when using the XML Stream API with moshi, nor 
whether this is supported at all.
    Am Dienstag, 18. Februar 2025 um 17:19:01 MEZ hat Jeff Greif 
<jgr...@alumni.princeton.edu> Folgendes geschrieben:  
 
 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 RobertUsing 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