In between I have also looked into the source of org.apache.axis2.json.moshi.MoshiXMLStreamReader and I find
public int getAttributeCount() { if (isStartElement()) { return 0; // don't support attributes on tags in JSON convention } else { throw new IllegalStateException("Only valid on START_ELEMENT state"); } } public QName getAttributeName(int index) { throw new UnsupportedOperationException("Method is not implemented"); } Attributes get ignored (attribute count will be returned as 0). It appears that I cannot use the current XML Stream API based approach togehter with ADB in my case, at least not without substantial changes in the used xml-schemas. Am Mittwoch, 19. Februar 2025 um 09:26:07 MEZ hat Stefan Traud <stefan_tr...@yahoo.com> Folgendes geschrieben: I'm attaching 2 debug logs: - soap.log: processing of the getPrice request using the ADBClient from samples.quickstartadb (modified only to set the required currency attribute using StockQuoteService.setCurrency). This returns the expected result. - json.log: processing of the getPrice request using a post of the json message string {"getPrice":{"@currency":"USD","symbol":"IBM"}} with content-type application/json and url http://localhost:8080/axis2/services/StockQuoteService/getPrice. This results in internal server error due to missing required attribute. For your reference, I'm also attaching the modified StockQuoteService.wsdl from the samples.quickstartadb (adding required attribute 'currency' to the getPrice data type). I also played with various variations of the json message (using "currency" instead of "@currency", changing order, or using "_attributes" : {"currency":"USD"}. This trial-and-error approach does not work. I also tried what happens if I change the wsdl to require an attribute in the getPriceResponse (instead of in the request), as this will use the moshi.JsonFormatter to write the output JSON (I hoped to see what convention would be used by moshi when producing the json string). However the attribute is simply ignored and not included in the response json. Am Dienstag, 18. Februar 2025 um 16:38:57 MEZ hat robertlazarski <robertlazar...@gmail.com> Folgendes geschrieben: 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?