Re: JSON with XML Stream API/moshi

robertlazarski <[email protected]> Tue, 18 Feb 2025 05:38:43 -1000
Newsgroups gmane.text.xml.axis.user
Message-ID <CABpPLBUL-SDdy_b8QHuUHn9PgHZxTHO4Gj+b+Vo8q0Pzybddxw@mail.gmail.com>
--00000000000047e7d7062e6c7017
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=E2=80=AFAM Stefan Traud <[email protected]=
m> 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?
>
>
>

--00000000000047e7d7062e6c7017
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Could you please paste or attach your logs? That may help =
me understand the problem better. I don&#39;t have use cases combining XML =
and JSON in my own projects but I know the code pretty well and I can proba=
bly help. <br></div><br><div class=3D"gmail_quote gmail_quote_container"><d=
iv dir=3D"ltr" class=3D"gmail_attr">On Mon, Feb 17, 2025 at 5:23=E2=80=AFAM=
 Stefan Traud &lt;<a href=3D"mailto:[email protected]">stefan_traud@ya=
hoo.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex"><div><div style=3D"font-family:Helvetica Neue,Helvetica,Arial,sans-s=
erif;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 our exis=
ting service with JSON support (based on XML Stream API with moshi).</div><=
div dir=3D"ltr"><br></div><div dir=3D"ltr">I&#39;m currently struggling wit=
h xml types that include attributes. To reproduce the issue I have amended =
the wsdl in the samples.quickstartadb to include an attribute in the getPri=
ce element:</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><div><div styl=
e=3D"padding:0px 0px 0px 2px"><div style=3D"color:rgb(0,0,0);font-family:Co=
nsolas;font-size:10pt"><p style=3D"margin:0px">			<span style=3D"color:rgb(=
0,128,128)">&lt;</span><span style=3D"color:rgb(63,127,127)">xs:element</sp=
an> <span style=3D"color:rgb(127,0,127)">name</span>=3D<span style=3D"color=
:rgb(42,0,255);font-style:italic">&quot;getPrice&quot;</span><span style=3D=
"color:rgb(0,128,128)">&gt;</span></p><p style=3D"margin:0px">				<span sty=
le=3D"color:rgb(0,128,128)">=C2=A0=C2=A0=C2=A0=C2=A0&lt;</span><span style=
=3D"color:rgb(63,127,127)">xs:complexType</span><span style=3D"color:rgb(0,=
128,128)">&gt;</span></p><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&lt;</span>=
<span style=3D"color:rgb(63,127,127)">xs:sequence</span><span style=3D"colo=
r:rgb(0,128,128)">&gt;</span></p><div style=3D"margin:0px"><span style=3D"c=
olor: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&lt;</span><span style=3D"color:rgb(63,127,127)">xs:eleme=
nt</span> <span style=3D"color:rgb(127,0,127)">name</span>=3D<span style=3D=
"color:rgb(42,0,255);font-style:italic">&quot;symbol&quot;</span>=C2=A0</di=
v><div style=3D"margin:0px"><span 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=A0=C2=A0=C2=A0=
=C2=A0=C2=A0nillable</span>=3D<span style=3D"color:rgb(42,0,255);font-style=
:italic">&quot;true&quot;=C2=A0</span><span style=3D"font-size:10pt;color:r=
gb(127,0,127)">type</span><span style=3D"font-size:10pt">=3D</span><span st=
yle=3D"font-size:10pt;color:rgb(42,0,255);font-style:italic">&quot;xs:strin=
g&quot;</span><span style=3D"font-size:10pt"> </span><span style=3D"font-si=
ze:10pt;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=C2=A0=C2=A0=
=C2=A0=C2=A0&lt;/</span><span style=3D"color:rgb(63,127,127)">xs:sequence</=
span><span style=3D"color:rgb(0,128,128)">&gt;</span></p><div style=3D"marg=
in: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&lt;</span><span style=3D"color:rgb(63,127,127)">xs:attri=
bute</span> <span style=3D"color:rgb(127,0,127)">name</span>=3D<span style=
=3D"color:rgb(42,0,255);font-style:italic">&quot;currency&quot;</span>=C2=
=A0</div><div style=3D"margin:0px"><span 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">&quot;xs:stri=
ng&quot;</span> <span style=3D"color:rgb(127,0,127)">use</span>=3D<span sty=
le=3D"color:rgb(42,0,255);font-style:italic">&quot;required&quot;</span><sp=
an 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&lt;/</sp=
an><span style=3D"color:rgb(63,127,127)">xs:complexType</span><span style=
=3D"color:rgb(0,128,128)">&gt;</span></p><p style=3D"margin:0px">			<span s=
tyle=3D"color:rgb(0,128,128)">&lt;/</span><span style=3D"color:rgb(63,127,1=
27)">xs:element</span><span style=3D"color:rgb(0,128,128)">&gt;</span></p><=
/div></div></div><br></div><div dir=3D"ltr">My corresponding JSON message s=
hould then be something like:</div><div dir=3D"ltr"><br></div><div dir=3D"l=
tr">{ &quot;getPrice&quot; : {&quot;@currency&quot;: &quot;USD&quot;, &quot=
;symbol&quot;: &quot;IBM&quot; }}</div><div dir=3D"ltr"><br></div><div dir=
=3D"ltr">However the parse method in the GetPrice ADBBean keeps complaining=
 &quot;<span><span style=3D"padding:0px 0px 0px 2px"><span style=3D"color:r=
gb(0,0,0);font-family:Consolas;font-size:10pt">Required attribute currency =
is missing</span></span></span>&quot;; specifically this call returns null:=
</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><div><div style=3D"paddin=
g: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"color:rgb(106,62,62)">=
reader</span>.getAttributeValue(<span style=3D"color:rgb(42,0,255)">&quot;<=
a href=3D"http://quickstart.samples/xsd" target=3D"_blank">http://quickstar=
t.samples/xsd</a>&quot;</span>, <span style=3D"color:rgb(42,0,255)">&quot;c=
urrency&quot;</span>);</div><div style=3D"margin:0px"><br></div></div></div=
></div>(However it works when using SOAP).</div><div dir=3D"ltr"><br></div>=
<div dir=3D"ltr">Do I need to define attributes differently in the JSON mes=
sage?</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div></div></di=
v></blockquote></div>

--00000000000047e7d7062e6c7017--