Re: JSON with XML Stream API/moshi
robertlazarski <[email protected]> Thu, 27 Feb 2025 05:38:25 -1000
| Newsgroups | gmane.text.xml.axis.user |
|---|---|
| Message-ID | <CABpPLBX30fJ05XD7wxrXTv696zyws4KhUZURJC6kGi_8jnc2MA@mail.gmail.com> |
--000000000000cb4dd5062f217b1d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks for posting your config files, that helped me understand a bit more of what you are trying to do as I only use the "native" JSON approach with POJO's at my day job. I haven't looked much at the Stax support code using the XMLSchema project. And you were correct in pointing out the comments indicating that attributes are not supported. Anyways, I gave the coding to support attributes a shot but ran out of time after getting about 80% the way there - ideally someone with this use case can complete the coding though our git repo code requires Tomcat 11 / Wildfly 32. See this commit. I created an attribute queue. If the JsonObject as an attribute would be added to the main queue, it would incorrectly end up as an Element in the SOAP body generated from JSONHandler. https://github.com/apache/axis-axis2-java-core/commit/16e832e71ef809ddd85de= 386b43719575d0a7b7c I also created this Jira issue: https://issues.apache.org/jira/browse/AXIS2-6081 What needs to happen is getAttributeCount() and getAttributeName() need to call nextName() and nextValue() with some type of flag that tells the method to switch to the attribute queue. With the current code, it will consider JSON with a currency attribute added invalid because it doesn't read all of it since this Stax streaming approach needs that JsonObject in the attributes queue. On Sun, Feb 23, 2025 at 10:42=E2=80=AFPM Stefan Traud <[email protected]= om> wrote: > I'm using the services.xml without modification as per > samples.quickstartadb.resources.META-INF.services.xml. Please see attache= d. > Regarding the axis2.xml, I have modified according to the guidelines in A= pache > Axis2 =E2=80=93 How to configure Native approach and XML Stream API base = approach > <https://axis.apache.org/docs/json_gson_user_guide.html> for the XML > Stream API based approach (and replacing occurences of "gson" with > "moshi"). Please find attached. > > In the transport phase, I have added: > > <handler name=3D"RequestURIOperationDispatcher" > > class=3D"org.apache.axis2.dispatchers.RequestURIOperationDispatcher"/> > > <handler name=3D"JSONMessageHandler" > class=3D"org.apache.axis2.json.moshi.JSONMessageHandler" /> > > > However, I have not modified the RequestURIBasedDispatcher that was > already there from the axis2-1.8.2 default axis2.xml as follows: > > <handler name=3D"RequestURIBasedDispatcher" > > class=3D"org.apache.axis2.dispatchers.RequestURIBasedDispatcher"> > > <order phase=3D"Transport"/> > > </handler> > > > > Regarding the moshi.MoshiXMLStreamReader: While I can not see any of the > unsupported methods being entered during debugging, I can see the > getAttributeCount method being invoked. This method always returns 0. > > Am Montag, 24. Februar 2025 um 07:00:14 MEZ hat robertlazarski < > [email protected]> Folgendes geschrieben: > > > I was able to follow your examples with the currency attribute and get > some results but it seems like you have some service.xml and axis2.xml > configurations I am unsure about - could you please post them? > > With the service.xml and axis2.xml largely from the spring boot demo I > conjured up with the current state of git master - the one difference is > you are using RequestURIBasedDispatcher instead of the new class > JSONBasedDefaultDispatcher > which works, so I used that too - I am sending this: > > {"getPrice":[{"arg0":{"currency":USD,"symbol":IBM}}]} > > And getting this response: > > {"response":{"local_return":42.0}} > > The problem is the skeleton is receiving null values for the currency and > symbol for some reason. > > About the MoshiXMLStreamReader question - I don't see that condition > being entered during my debugging. > > > On Fri, Feb 21, 2025 at 12:52=E2=80=AFAM Stefan Traud <stefan_traud@yahoo= .com> > wrote: > > 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 appear= s > 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 < > [email protected]> 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 expec= ted > 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.wsd= l > from the samples.quickstartadb (adding required attribute 'currency' to t= he > 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 mo= shi.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 < > [email protected]> 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 o= wn > projects but I know the code pretty well and I can probably help. > > On Mon, Feb 17, 2025 at 5:23=E2=80=AFAM Stefan Traud <stefan_traud@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 mosh= i). > > 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=3D"getPrice"> > > <xs:complexType> > > <xs:sequence> > <xs:element name=3D"symbol" > nillable=3D"true" type=3D"xs:string" /> > > </xs:sequence> > <xs:attribute name=3D"currency" > type=3D"xs:string" use=3D"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 "Requi= red > 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? > > > --000000000000cb4dd5062f217b1d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Thanks for posting your config files, that helped me = understand a bit more of what you are trying to do as I only use the "= native" JSON approach with POJO's at my day job. I haven't loo= ked much at the Stax support code using the XMLSchema project.</div><div><b= r></div><div>And you were correct in pointing out the comments indicating t= hat attributes are not supported. <br></div><div><br></div><div>Anyways, I = gave the coding to support attributes a shot but ran out of time after gett= ing about 80% the way there - ideally someone with this use case can comple= te the coding though our git repo code requires Tomcat 11 / Wildfly 32. <br= ></div><div><br></div><div> See this commit. I created an attribute queue. = If the JsonObject as an attribute would be added to the main queue, it woul= d incorrectly end up as an Element in the SOAP body generated from JSONHand= ler. <br></div><div><br></div><div><a href=3D"https://github.com/apache/axi= s-axis2-java-core/commit/16e832e71ef809ddd85de386b43719575d0a7b7c">https://= github.com/apache/axis-axis2-java-core/commit/16e832e71ef809ddd85de386b4371= 9575d0a7b7c</a></div><div><br></div><div>I also created this Jira issue:</d= iv><div><br></div><div><a href=3D"https://issues.apache.org/jira/browse/AXI= S2-6081">https://issues.apache.org/jira/browse/AXIS2-6081</a></div><div><br= ></div><div>What needs to happen is getAttributeCount() and getAttributeNam= e() need to call nextName() and <span style=3D"font-family:monospace"><span= style=3D"color:rgb(0,0,0);background-color:rgb(255,255,255)">nextValue()</= span><br></span>with some type of flag that tells the method to switch to t= he attribute queue.=C2=A0 <br></div><div><br></div><div>With the current co= de, it will consider JSON with a currency attribute added invalid because i= t doesn't read all of it since this Stax streaming approach needs that = JsonObject in the attributes queue. <br></div></div><br><div class=3D"gmail= _quote"><div dir=3D"ltr" class=3D"gmail_attr">On Sun, Feb 23, 2025 at 10:42= =E2=80=AFPM Stefan Traud <<a href=3D"mailto:[email protected]" targ= et=3D"_blank">[email protected]</a>> wrote:<br></div><blockquote cl= ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid= rgb(204,204,204);padding-left:1ex"><div><div style=3D"font-family:Helvetic= a Neue,Helvetica,Arial,sans-serif;font-size:13px"><div></div> <div dir=3D"ltr">I'm using the services.xml without modificatio= n as per samples.quickstartadb.resources.META-INF.services.xml. Please see = attached. Regarding the axis2.xml, I have modified according to the guideli= nes in=C2=A0<span><a href=3D"https://axis.apache.org/docs/json_gson_user_gu= ide.html" rel=3D"nofollow" target=3D"_blank">Apache Axis2 =E2=80=93 How to = configure Native approach and XML Stream API base approach</a>=C2=A0for the= XML Stream API based approach (and replacing occurences of "gson"= ; with "moshi"). Please find attached.</span></div><div dir=3D"lt= r"><span><br></span></div><div dir=3D"ltr"><span>In the transport phase, I = have added:</span></div><div dir=3D"ltr"><span><br></span></div><div dir=3D= "ltr"><div style=3D"padding:0px 0px 0px 2px"><div style=3D"color:rgb(0,0,0)= ;font-family:Consolas;font-size:10pt"><p style=3D"margin:0px"><span style= =3D"color:rgb(0,128,128)"><</span><span style=3D"color:rgb(63,127,127)">= handler</span> <span style=3D"color:rgb(127,0,127)">name</span>=3D<span sty= le=3D"color:rgb(42,0,255);font-style:italic">"RequestURIOperationDispa= tcher"</span></p><p style=3D"margin:0px"> = <span style=3D"color:rgb(127,0,127)">class</span>=3D<span style=3D"color:rg= b(42,0,255);font-style:italic">"org.apache.axis2.dispatchers.RequestUR= IOperationDispatcher"</span><span style=3D"color:rgb(0,128,128)">/>= </span></p><p style=3D"margin:0px"> <span style=3D"color:rgb(0,1= 28,128)"><</span><span style=3D"color:rgb(63,127,127)">handler</span> <s= pan style=3D"color:rgb(127,0,127)">name</span>=3D<span style=3D"color:rgb(4= 2,0,255);font-style:italic">"JSONMessageHandler"</span></p><div s= tyle=3D"margin:0px"><span style=3D"color:rgb(127,0,127)">class</span>=3D<sp= an style=3D"color:rgb(42,0,255);font-style:italic">"org.apache.axis2.j= son.moshi.JSONMessageHandler"</span> <span style=3D"color:rgb(0,128,12= 8)">/></span></div></div></div></div><div dir=3D"ltr"><br></div><div dir= =3D"ltr"><br></div><div dir=3D"ltr">However, I have not modified the <span = style=3D"padding:0px 0px 0px 2px"><span style=3D"font-family:Consolas;font-= size:10pt"><span style=3D"color:rgb(42,0,255);font-style:italic">RequestURI= BasedDispatcher </span></span></span>that was already there from the axis2-= 1.8.2 default axis2.xml as follows:</div><div dir=3D"ltr"><span><br></span>= </div><div dir=3D"ltr"><div style=3D"padding:0px 0px 0px 2px"><div style=3D= "color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><p style=3D"margin:0= px" dir=3D"ltr"> </p><div><div style=3D"padding:0px 0px 0px 2px"><div style= =3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><p style=3D"margi= n:0px"><span style=3D"color:rgb(0,128,128)"><</span><span style=3D"color= :rgb(63,127,127);background-color:rgb(212,212,212)">handler</span> <span st= yle=3D"color:rgb(127,0,127)">name</span>=3D<span style=3D"color:rgb(42,0,25= 5);font-style:italic">"RequestURIBasedDispatcher"</span></p><p st= yle=3D"margin:0px"> <span style=3D"color:rgb(127,0,127)= ">class</span>=3D<span style=3D"color:rgb(42,0,255);font-style:italic">&quo= t;org.apache.axis2.dispatchers.RequestURIBasedDispatcher"</span><span = style=3D"color:rgb(0,128,128)">></span></p><p style=3D"margin:0px"> = <span style=3D"color:rgb(0,128,128)"><</span><span style=3D"c= olor:rgb(63,127,127)">order</span> <span style=3D"color:rgb(127,0,127)">pha= se</span>=3D<span style=3D"color:rgb(42,0,255);font-style:italic">"Tra= nsport"</span><span style=3D"color:rgb(0,128,128)">/></span></p><p = style=3D"margin:0px"> <span style=3D"color:rgb(0,128,128)"></= </span><span style=3D"color:rgb(63,127,127);background-color:rgb(212,212,21= 2)">handler</span><span style=3D"color:rgb(0,128,128)">></span></p></div= ></div></div><p></p><div style=3D"margin:0px"><br></div></div></div></div><= div dir=3D"ltr"><br></div><div dir=3D"ltr"><span>Regarding the moshi.MoshiX= MLStreamReader: While I can not see any of the unsupported methods being en= tered during debugging, I can see the getAttributeCount method being invoke= d. This method always returns 0.=C2=A0</span></div><div><br></div> =20 </div><div id=3D"m_-6451814267192055376m_3835683055986474251yahoo_q= uoted_1177848542"> <div style=3D"font-family:"Helvetica Neue",Helvetica,= Arial,sans-serif;font-size:13px;color:rgb(38,40,42)"> =20 <div> Am Montag, 24. Februar 2025 um 07:00:14 MEZ hat rob= ertlazarski <<a href=3D"mailto:[email protected]" target=3D"_blan= k">[email protected]</a>> Folgendes geschrieben: </div> <div><br></div> <div><br></div> =20 =20 <div><div id=3D"m_-6451814267192055376m_3835683055986474251= yiv2506349534"><div><div dir=3D"ltr"><div>I was able to follow your example= s with the currency attribute and get some results but it seems like you ha= ve some service.xml and axis2.xml configurations I am unsure about - could = you please post them? <br clear=3D"none"></div><div><br clear=3D"none"></di= v><div>With the service.xml and axis2.xml largely from the spring boot demo= I conjured up with the current state of git master - the one difference is= you are using=C2=A0<span style=3D"font-family:monospace"><span style=3D"co= lor:rgb(0,0,0);background-color:rgb(255,255,255)">RequestURIBasedDispatcher= </span></span> instead of the new class <span style=3D"font-family:monospac= e"><span style=3D"color:rgb(0,0,0);background-color:rgb(255,255,255)">JSONB= asedDefaultDispatcher</span><br clear=3D"none"></span>which works, so I use= d that too - I am sending this: <br clear=3D"none"></div><div><br clear=3D"= none"></div><div><span style=3D"font-family:monospace"><span style=3D"color= :rgb(0,0,0);background-color:rgb(255,255,255)">{"getPrice":[{&quo= t;arg0":{"currency":USD,"symbol":IBM}}]}</span><br= clear=3D"none"></span></div><div><span style=3D"font-family:monospace"><br= clear=3D"none"></span></div><div><span style=3D"font-family:monospace">And= getting this response: <br clear=3D"none"></span></div><div><span style=3D= "font-family:monospace"><br clear=3D"none"></span></div><div><span style=3D= "font-family:monospace"><span style=3D"color:rgb(0,0,0);background-color:rg= b(255,255,255)">{"response":{"local_return":42.0}}</spa= n><br clear=3D"none"></span></div><div><span style=3D"font-family:monospace= "><br clear=3D"none"></span></div><div><span style=3D"font-family:monospace= ">The problem is the skeleton is receiving null values for the currency and= symbol for some reason. <br clear=3D"none"></span></div><div><br clear=3D"= none"></div><div>About the <span style=3D"font-family:monospace"><span styl= e=3D"color:rgb(0,0,0);background-color:rgb(255,255,255)">MoshiXMLStreamRead= er question - I don't see that condition being entered during my debugg= ing. </span><br clear=3D"none"></span><br clear=3D"none"></div></div><br cl= ear=3D"none"><div id=3D"m_-6451814267192055376m_3835683055986474251yiv25063= 49534yqt77091"><div><div dir=3D"ltr">On Fri, Feb 21, 2025 at 12:52=E2=80=AF= AM Stefan Traud <<a rel=3D"nofollow noopener noreferrer" shape=3D"rect" = href=3D"mailto:[email protected]" target=3D"_blank">stefan_traud@yahoo= .com</a>> wrote:<br clear=3D"none"></div><blockquote style=3D"margin:0px= 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di= v><div style=3D"font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-= size:13px"><div></div> <div dir=3D"ltr">In between I have also looked into the source of o= rg.apache.axis2.json.moshi.MoshiXMLStreamReader and I find</div><div dir=3D= "ltr"><br clear=3D"none"></div><div dir=3D"ltr"><div><div style=3D"padding:= 0px 0px 0px 2px"><div style=3D"font-family:Consolas;font-size:10pt"><p styl= e=3D"color:rgb(0,0,0);margin:0px"><span style=3D"color:rgb(127,0,85);font-w= eight:bold">public</span> <span style=3D"color:rgb(127,0,85);font-weight:bo= ld">int</span> getAttributeCount() {</p><p style=3D"color:rgb(0,0,0);margin= :0px"> <span style=3D"color:rgb(127,0,85);font-weight:bold">if</span= > (isStartElement()) {</p><p style=3D"margin:0px"> <span style= =3D"color:rgb(127,0,85);font-weight:bold">return</span> 0; <font color=3D"#= cd232c"><b>//</b></font><span style=3D"color:rgb(63,127,95)"> </span><font = color=3D"#cd232c"><b>don't support attributes on tags in JSON conventi= on</b></font></p><p style=3D"color:rgb(0,0,0);margin:0px"> } <span s= tyle=3D"color:rgb(127,0,85);font-weight:bold">else</span> {</p><p style=3D"= color:rgb(0,0,0);margin:0px"> <span style=3D"color:rgb(127,0,85)= ;font-weight:bold">throw</span> <span style=3D"color:rgb(127,0,85);font-wei= ght:bold">new</span> IllegalStateException(<span style=3D"color:rgb(42,0,25= 5)">"Only valid on START_ELEMENT state"</span>);</p><p style=3D"c= olor:rgb(0,0,0);margin:0px"> }</p><p style=3D"color:rgb(0,0,0);margi= n:0px"> }</p><p style=3D"color:rgb(0,0,0);margin:0px"><br clear=3D"none"= ></p><p style=3D"color:rgb(0,0,0);margin:0px"> <span style=3D"color:rgb(= 127,0,85);font-weight:bold">public</span> QName getAttributeName(<span styl= e=3D"color:rgb(127,0,85);font-weight:bold">int</span> <span style=3D"color:= rgb(106,62,62)">index</span>) {</p><p style=3D"color:rgb(0,0,0);margin:0px"= > <span style=3D"color:rgb(127,0,85);font-weight:bold">throw</span> = <span style=3D"color:rgb(127,0,85);font-weight:bold">new</span> Unsupported= OperationException(<span style=3D"color:rgb(42,0,255)">"Method is not = implemented"</span>);</p><div style=3D"color:rgb(0,0,0);margin:0px"> = }</div><div style=3D"color:rgb(0,0,0);margin:0px"><br clear=3D"none"></di= v><div dir=3D"ltr" style=3D"color:rgb(0,0,0);margin:0px">Attributes get ign= ored (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.</div></div><= /div></div><br clear=3D"none"></div><div><br clear=3D"none"></div> =20 </div><div id=3D"m_-6451814267192055376m_3835683055986474251yiv2506= 349534m_-1352858088099866023yahoo_quoted_0984148450"> <div style=3D"font-family:Helvetica,Arial,sans-serif;font-size:= 13px;color:rgb(38,40,42)"> =20 <div> Am Mittwoch, 19. Februar 2025 um 09:26:07 MEZ hat S= tefan Traud <<a rel=3D"nofollow noopener noreferrer" shape=3D"rect" href= =3D"mailto:[email protected]" target=3D"_blank">[email protected]= </a>> Folgendes geschrieben: </div> <div><br clear=3D"none"></div> <div><br clear=3D"none"></div> =20 =20 <div><div id=3D"m_-6451814267192055376m_3835683055986474251= yiv2506349534m_-1352858088099866023yiv9955715974"><div><div style=3D"font-f= amily:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:13px"><div></div> <div dir=3D"ltr">I'm attaching 2 debug logs:</div><div dir=3D"l= tr"><ul dir=3D"ltr"><li>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.</li><li>json.log: processing of the getPrice request using= a post of the json message string=C2=A0<span>{"getPrice":{"= @currency":"USD","symbol":"IBM"}} with c= ontent-type application/json and url=C2=A0</span><a rel=3D"nofollow noopene= r noreferrer" shape=3D"rect" href=3D"http://localhost:8080/axis2/services/S= tockQuoteService/getPrice." target=3D"_blank">http://localhost:8080/axis2/s= ervices/StockQuoteService/getPrice.</a>=C2=A0This results in internal serve= r error due to missing required attribute.</li></ul><div><br clear=3D"none"= ></div><div dir=3D"ltr">For your reference, I'm also attaching the modi= fied StockQuoteService.wsdl from the samples.quickstartadb (adding required= attribute 'currency' to the getPrice data type).</div><div dir=3D"= ltr"><br clear=3D"none"></div><div dir=3D"ltr">I also played with various v= ariations of the json message (using "currency" instead of "= @currency", changing order, or using "_attributes" : {"= currency":"USD"}. This trial-and-error approach does not wor= k.</div><div dir=3D"ltr"><br clear=3D"none"></div><div dir=3D"ltr">I also t= ried what happens if I change the wsdl to require an attribute in the getPr= iceResponse (instead of in the request), as this will use the=C2=A0<span>mo= shi.JsonFormatter to write the output JSON (I hoped to see what convention = would be used by moshi when producing the json string). However the attribu= te is simply ignored and not included in the response json.</span></div></d= iv><div><br clear=3D"none"></div> =20 </div><div id=3D"m_-6451814267192055376m_3835683055986474251yiv2506= 349534m_-1352858088099866023yiv9955715974yahoo_quoted_0201809127"> <div style=3D"font-family:Helvetica,Arial,sans-serif;font-size:= 13px;color:rgb(38,40,42)"> =20 <div> Am Dienstag, 18. Februar 2025 um 16:38:57 MEZ hat r= obertlazarski <<a rel=3D"nofollow noopener noreferrer" shape=3D"rect" hr= ef=3D"mailto:[email protected]" target=3D"_blank">robertlazarski@gma= il.com</a>> Folgendes geschrieben: </div> <div><br clear=3D"none"></div> <div><br clear=3D"none"></div> =20 =20 <div id=3D"m_-6451814267192055376m_3835683055986474251yiv25= 06349534m_-1352858088099866023yiv9955715974yqt48543"><div><div id=3D"m_-645= 1814267192055376m_3835683055986474251yiv2506349534m_-1352858088099866023yiv= 9955715974"><div><div dir=3D"ltr">Could you please paste or attach your log= s? That may help me understand the problem better. I don't have use cas= es combining XML and JSON in my own projects but I know the code pretty wel= l and I can probably help. <br clear=3D"none"></div><br clear=3D"none"><div= id=3D"m_-6451814267192055376m_3835683055986474251yiv2506349534m_-135285808= 8099866023yiv9955715974yqt01052"><div><div dir=3D"ltr">On Mon, Feb 17, 2025= at 5:23=E2=80=AFAM Stefan Traud <<a rel=3D"nofollow noopener noreferrer= " shape=3D"rect" href=3D"mailto:[email protected]" target=3D"_blank">s= [email protected]</a>> wrote:<br clear=3D"none"></div><blockquote st= yle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padd= ing-left:1ex"><div><div style=3D"font-family:Helvetica Neue,Helvetica,Arial= ,sans-serif;font-size:13px"><div dir=3D"ltr">Hi Robert</div><div dir=3D"ltr= ">Using contract first with ADB, I continue to check feasibility to amend o= ur existing service with JSON support (based on XML Stream API with moshi).= </div><div dir=3D"ltr"><br clear=3D"none"></div><div dir=3D"ltr">I'm cu= rrently struggling with xml types that include attributes. To reproduce the= issue I have amended the wsdl in the samples.quickstartadb to include an a= ttribute in the getPrice element:</div><div dir=3D"ltr"><br clear=3D"none">= </div><div dir=3D"ltr"><div><div style=3D"padding:0px 0px 0px 2px"><div sty= le=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><p style=3D"mar= gin:0px"> <span style=3D"color:rgb(0,128,128)"><</span><span style=3D"= color:rgb(63,127,127)">xs:element</span> <span style=3D"color:rgb(127,0,127= )">name</span>=3D<span style=3D"color:rgb(42,0,255);font-style:italic">&quo= t;getPrice"</span><span style=3D"color:rgb(0,128,128)">></span></p>= <p style=3D"margin:0px"> <span style=3D"color:rgb(0,128,128)">=C2=A0=C2= =A0=C2=A0=C2=A0<</span><span style=3D"color:rgb(63,127,127)">xs:complexT= ype</span><span style=3D"color:rgb(0,128,128)">></span></p><p style=3D"m= argin:0px"> <span style=3D"color:rgb(0,128,128)">=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0<</span><span style=3D"color:rgb(63,127,127)"= >xs:sequence</span><span style=3D"color:rgb(0,128,128)">></span></p><div= style=3D"margin:0px"><span style=3D"color:rgb(0,128,128)">=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0<</span><span s= tyle=3D"color:rgb(63,127,127)">xs:element</span> <span style=3D"color:rgb(1= 27,0,127)">name</span>=3D<span style=3D"color:rgb(42,0,255);font-style:ital= ic">"symbol"</span>=C2=A0</div><div style=3D"margin:0px"><span st= yle=3D"color:rgb(127,0,127)">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0nillable</span>=3D<span = style=3D"color:rgb(42,0,255);font-style:italic">"true"=C2=A0</spa= n><span style=3D"font-size:10pt;color:rgb(127,0,127)">type</span><span styl= e=3D"font-size:10pt">=3D</span><span style=3D"font-size:10pt;color:rgb(42,0= ,255);font-style:italic">"xs:string"</span><span style=3D"font-si= ze:10pt"> </span><span style=3D"font-size:10pt;color:rgb(0,128,128)">/><= /span></div><p style=3D"margin:0px"> <span style=3D"color:rgb(0,128,128= )">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0</</span><span style= =3D"color:rgb(63,127,127)">xs:sequence</span><span style=3D"color:rgb(0,128= ,128)">></span></p><div style=3D"margin:0px"><span style=3D"color:rgb(0,= 128,128)">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0<</span><span = style=3D"color:rgb(63,127,127)">xs:attribute</span> <span style=3D"color:rg= b(127,0,127)">name</span>=3D<span style=3D"color:rgb(42,0,255);font-style:i= talic">"currency"</span>=C2=A0</div><div style=3D"margin:0px"><sp= an style=3D"color:rgb(127,0,127)">=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0type</span>=3D<span style=3D"color:rgb(42,= 0,255);font-style:italic">"xs:string"</span> <span style=3D"color= :rgb(127,0,127)">use</span>=3D<span style=3D"color:rgb(42,0,255);font-style= :italic">"required"</span><span style=3D"color:rgb(0,128,128)">/&= gt;</span></div><p style=3D"margin:0px"> <span style=3D"color:rgb(0,128,= 128)">=C2=A0=C2=A0=C2=A0=C2=A0</</span><span style=3D"color:rgb(63,127,1= 27)">xs:complexType</span><span style=3D"color:rgb(0,128,128)">></span><= /p><p style=3D"margin:0px"> <span style=3D"color:rgb(0,128,128)"></</s= pan><span style=3D"color:rgb(63,127,127)">xs:element</span><span style=3D"c= olor:rgb(0,128,128)">></span></p></div></div></div><br clear=3D"none"></= div><div dir=3D"ltr">My corresponding JSON message should then be something= like:</div><div dir=3D"ltr"><br clear=3D"none"></div><div dir=3D"ltr">{ &q= uot;getPrice" : {"@currency": "USD", "symbol&= quot;: "IBM" }}</div><div dir=3D"ltr"><br clear=3D"none"></div><d= iv dir=3D"ltr">However the parse method in the GetPrice ADBBean keeps compl= aining "<span><span style=3D"padding:0px 0px 0px 2px"><span style=3D"c= olor:rgb(0,0,0);font-family:Consolas;font-size:10pt">Required attribute cur= rency is missing</span></span></span>"; specifically this call returns= null:</div><div dir=3D"ltr"><br clear=3D"none"></div><div dir=3D"ltr"><div= ><div style=3D"padding:0px 0px 0px 2px"><div style=3D"color:rgb(0,0,0);font= -family:Consolas;font-size:10pt"><div style=3D"margin:0px"><span style=3D"c= olor:rgb(106,62,62)">reader</span>.getAttributeValue(<span style=3D"color:r= gb(42,0,255)">"<a rel=3D"nofollow noopener noreferrer" shape=3D"rect" = href=3D"http://quickstart.samples/xsd" target=3D"_blank">http://quickstart.= samples/xsd</a>"</span>, <span style=3D"color:rgb(42,0,255)">"cur= rency"</span>);</div><div style=3D"margin:0px"><br clear=3D"none"></di= v></div></div></div>(However it works when using SOAP).</div><div dir=3D"lt= r"><br clear=3D"none"></div><div dir=3D"ltr">Do I need to define attributes= differently in the JSON message?</div><div dir=3D"ltr"><br clear=3D"none">= </div><div dir=3D"ltr"><br clear=3D"none"></div></div></div></blockquote></= div></div> </div></div></div></div> </div> </div></div></div></div> </div> </div></div></blockquote></div></div> </div></div></div> </div> </div></div></blockquote></div> --000000000000cb4dd5062f217b1d--