Re: moshi.JSONBuilder not building SOAP body from JSON

robertlazarski <[email protected]> Wed, 12 Feb 2025 09:40:58 -1000
Newsgroups gmane.text.xml.axis.user
Message-ID <CABpPLBXX=9baxJqznbbWx66m-2AKyng1kYMsB+Hw4gjc0_jCvw@mail.gmail.com>
--0000000000009193ee062df71f5a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I use Moshi with Axis2 quite a bit at my day job, and the 2.0.0 release
that is about to go out very soon has improved this area of Axis2.

For 1.8.2 we have samples and a user guide for Moshi. It is based on Spring
Boot but that is just for demonstration and it is not a requirement. This
guide has been updated in our Axis2 GitHub repo.

https://axis.apache.org/axis2/java/core/docs/json-springboot-userguide.html

My best guess on your problem is an axis2.xml issue somehow, so a glance at
the user guide axis2.xml is my suggestion. Also, the client needs that JSoN
syntax.

Let us know if you still need help.



On Wed, Feb 12, 2025 at 12:45=E2=80=AFAM Stefan Traud
<[email protected]> wrote:

> We are investigating to enhance our running axis2 service with JSON
> support, i.e. to use JSON over SOAP to facilitate support non-java client=
s.
>
> I'm doing feasibility checks for mapped JSON using the StockQuoteService
> from samples.quickstartadb in axis-1.8.2 (as described in JSON support in
> Axis2 tutorial)
>
> With the JSONOMBuilder this works as expected:
> axis2.xml:
> <messageBuilder contentType=3D"application/json"
> class=3D"org.apache.axis2.json.JSONOMBuilder"/>
>
> JSON message for operation 'getPrice': {"getPrice":{"symbol":"IBM"}}
> SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
>  <soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelope/=
"><getPrice
> xmlns=3D"http://quickstart.samples/xsd
> "><symbol>IBM</symbol></getPrice></soapenv:Body>
>
> However when I switch to the moshi.JSONBuilder, the SOAP Body will be
> empty:
> axis2.xml:
> <messageBuilder contentType=3D"application/json" class=3D"org.apache.axis=
2.json.moshi.JsonBuilder"
> />
>
> SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
>   <soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelope=
/
> "/>
>
> Getting the wrapped param with fromOM will then fail in
>
> fromOM(
>
> msgContext.getEnvelope().getBody().getFirstElement(),
>
> samples.quickstart.service.adb.xsd.GetPrice.class);
>
> with AxisFault "Cannot invoke
> "org.apache.axiom.om.OMElement.getXMLStreamReaderWithoutCaching()" becaus=
e
> "param" is null"
>
> What am I missing? Can the moshi.JSONBuilder not be used for mapped JSON
> with ADB?
>
>
>
>
>

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

<div dir=3D"ltr"><div>I use Moshi with Axis2 quite a bit at my day job, and=
 the 2.0.0 release that is about to go out very soon has improved this area=
 of Axis2. <br></div><div><br></div><div>For 1.8.2 we have samples and a us=
er guide for Moshi. It is based on Spring Boot but that is just for demonst=
ration and it is not a requirement. This guide has been updated in our Axis=
2 GitHub repo. <br></div><div><br></div><div><a href=3D"https://axis.apache=
.org/axis2/java/core/docs/json-springboot-userguide.html">https://axis.apac=
he.org/axis2/java/core/docs/json-springboot-userguide.html</a></div><div><b=
r></div><div>My best guess on your problem is an axis2.xml issue somehow, s=
o a glance at the user guide axis2.xml is my suggestion. Also, the client n=
eeds that JSoN syntax. <br></div><div><br></div><div>Let us know if you sti=
ll need help. <br></div><div><br></div><div><br></div></div><br><div class=
=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr=
">On Wed, Feb 12, 2025 at 12:45=E2=80=AFAM Stefan Traud &lt;stefan_traud@ya=
hoo.com.invalid&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=
-left:1ex"><div><div style=3D"font-family:Helvetica Neue,Helvetica,Arial,sa=
ns-serif;font-size:13px"><div dir=3D"ltr">We are investigating to enhance o=
ur running axis2 service with JSON support, i.e. to use JSON over SOAP to f=
acilitate support non-java clients.</div><div dir=3D"ltr"><br></div><div di=
r=3D"ltr">I&#39;m doing feasibility checks for mapped JSON using the StockQ=
uoteService from samples.quickstartadb in axis-1.8.2 (as described in JSON =
support in Axis2 tutorial)</div><div dir=3D"ltr"><br></div><div dir=3D"ltr"=
>With the JSONOMBuilder this works as expected:</div><div dir=3D"ltr">axis2=
.xml:</div><div dir=3D"ltr"><div><div style=3D"padding:0px 0px 0px 2px"><di=
v style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><div style=
=3D"margin:0px">&lt;messageBuilder contentType=3D&quot;application/<span st=
yle=3D"text-decoration-line:underline;text-decoration-color:rgb(255,128,64)=
;text-decoration-style:wavy">json</span>&quot;=C2=A0<span style=3D"font-siz=
e:10pt">class=3D&quot;org.apache.axis2.json.JSONOMBuilder&quot;/&gt;</span>=
</div><div style=3D"margin:0px" dir=3D"ltr"><span style=3D"font-size:10pt">=
<span><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot=
;,Helvetica,Arial,sans-serif"><br></span></span></span></div><div style=3D"=
margin:0px" dir=3D"ltr"><span style=3D"font-size:10pt"><span><span style=3D=
"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sa=
ns-serif">JSON message for operation &#39;getPrice&#39;:=C2=A0<span><span s=
tyle=3D"padding:0px 0px 0px 2px"><span style=3D"color:rgb(0,0,0);font-famil=
y:Consolas;font-size:10pt"><span style=3D"color:rgb(42,0,255)">{&quot;getPr=
ice&quot;:{&quot;symbol&quot;:&quot;IBM&quot;}}</span></span></span></span>=
</span></span></span></div><div style=3D"margin:0px" dir=3D"ltr"><span styl=
e=3D"font-size:10pt"><span><span style=3D"color:rgb(0,0,0);font-family:&quo=
t;Helvetica Neue&quot;,Helvetica,Arial,sans-serif"><span><span style=3D"pad=
ding:0px 0px 0px 2px"><span style=3D"color:rgb(0,0,0);font-family:Consolas;=
font-size:10pt"><span style=3D"color:rgb(42,0,255)"><span><span style=3D"co=
lor:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-=
serif;font-size:13.3333px">SOAP body in StockQuoteServiceMessageReceiverInO=
ut.invokeBusinessLogic:<br>=C2=A0<span><span style=3D"padding:0px 0px 0px 2=
px"><span style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt">&l=
t;soapenv:Body xmlns:soapenv=3D&quot;<a href=3D"http://schemas.xmlsoap.org/=
soap/envelope/" target=3D"_blank">http://schemas.xmlsoap.org/soap/envelope/=
</a>&quot;&gt;&lt;getPrice xmlns=3D&quot;<a href=3D"http://quickstart.sampl=
es/xsd" target=3D"_blank">http://quickstart.samples/xsd</a>&quot;&gt;&lt;sy=
mbol&gt;IBM&lt;/symbol&gt;&lt;/getPrice&gt;&lt;/soapenv:Body&gt;</span></sp=
an></span></span></span></span></span></span></span></span></span></span></=
div><div style=3D"margin:0px" dir=3D"ltr"><span style=3D"font-size:10pt"><s=
pan><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,=
Helvetica,Arial,sans-serif"><span><span style=3D"padding:0px 0px 0px 2px"><=
span style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><span s=
tyle=3D"color:rgb(42,0,255)"><span><span style=3D"color:rgb(0,0,0);font-fam=
ily:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333=
px"><span><span style=3D"padding:0px 0px 0px 2px"><span style=3D"color:rgb(=
0,0,0);font-family:Consolas;font-size:10pt"><br></span></span></span></span=
></span></span></span></span></span></span></span></span></div><div style=
=3D"margin:0px" dir=3D"ltr"><div><div dir=3D"ltr" style=3D"color:rgb(0,0,0)=
;font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif">However=
 when I switch to the moshi.JSONBuilder, the SOAP Body will be empty:</div>=
<div dir=3D"ltr" style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue=
&quot;,Helvetica,Arial,sans-serif">axis2.xml:</div><div dir=3D"ltr" style=
=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial=
,sans-serif"><div style=3D"padding:0px 0px 0px 2px"><div style=3D"font-fami=
ly:Consolas;font-size:10pt"><div style=3D"margin:0px" dir=3D"ltr"> <div><di=
v style=3D"padding:0px 0px 0px 2px"><div style=3D"color:rgb(0,0,0);font-fam=
ily:Consolas;font-size:10pt"><div style=3D"margin:0px">&lt;messageBuilder c=
ontentType=3D&quot;application/<span style=3D"text-decoration-line:underlin=
e;text-decoration-color:rgb(255,128,64);text-decoration-style:wavy">json</s=
pan>&quot;=C2=A0<span style=3D"font-size:10pt">class=3D&quot;org.apache.axi=
s2.json.moshi.JsonBuilder&quot; /&gt;</span></div><div style=3D"margin:0px"=
><span style=3D"font-size:10pt"><br></span></div><div style=3D"margin:0px" =
dir=3D"ltr"><div dir=3D"ltr"><span style=3D"color:rgb(0,0,0);font-family:&q=
uot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px">SO=
AP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:</span=
><br style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helve=
tica,Arial,sans-serif;font-size:13.3333px"><span style=3D"color:rgb(0,0,0);=
font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size=
:13.3333px">=C2=A0</span> <span><span style=3D"padding:0px 0px 0px 2px"><sp=
an style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt">&lt;soape=
nv:Body xmlns:soapenv=3D&quot;<a href=3D"http://schemas.xmlsoap.org/soap/en=
velope/" target=3D"_blank">http://schemas.xmlsoap.org/soap/envelope/</a>&qu=
ot;/&gt;</span></span></span></div><div dir=3D"ltr"><span><span style=3D"pa=
dding:0px 0px 0px 2px"><span style=3D"color:rgb(0,0,0);font-family:Consolas=
;font-size:10pt"><br></span></span></span></div><div dir=3D"ltr"><span><spa=
n style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetic=
a,Arial,sans-serif;font-size:13.3333px">Getting the wrapped param with from=
OM will then fail in<br></span></span><div><div style=3D"padding:0px 0px 0p=
x 2px"><div style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt">=
<p style=3D"margin:0px">fromOM(</p><p style=3D"margin:0px">                =
      <span style=3D"color:rgb(106,62,62)">msgContext</span>.getEnvelope().=
getBody().getFirstElement(),</p><p style=3D"margin:0px">                   =
   samples.quickstart.service.adb.xsd.GetPrice.<span style=3D"color:rgb(127=
,0,85);font-weight:bold">class</span>);</p></div></div></div><br></div><div=
 dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvet=
ica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px">with AxisFau=
lt &quot;<span><span style=3D"padding:0px 0px 0px 2px"><span style=3D"color=
:rgb(0,0,0);font-family:Consolas;font-size:10pt">Cannot invoke &quot;org.ap=
ache.axiom.om.OMElement.getXMLStreamReaderWithoutCaching()&quot; because &q=
uot;param&quot; is null</span></span></span>&quot;</span></span><br></div><=
div dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family:&quot;Hel=
vetica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px"><br></spa=
n></span></div><div dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-=
family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3=
333px"><span><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Ne=
ue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px">What am I missing?=
 Can the moshi.JSONBuilder not be used for mapped JSON with ADB?</span></sp=
an><br></span></span></div></div></div></div></div><br></div></div></div></=
div></div><br></div><div style=3D"margin:0px" dir=3D"ltr"><span style=3D"fo=
nt-size:10pt"><span><span style=3D"color:rgb(0,0,0);font-family:&quot;Helve=
tica Neue&quot;,Helvetica,Arial,sans-serif"><span><span style=3D"padding:0p=
x 0px 0px 2px"><span style=3D"color:rgb(0,0,0);font-family:Consolas;font-si=
ze:10pt"><span style=3D"color:rgb(42,0,255)"><span><span style=3D"color:rgb=
(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;f=
ont-size:13.3333px"><span><span style=3D"padding:0px 0px 0px 2px"><span sty=
le=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><br></span></sp=
an></span></span></span></span></span></span></span></span></span></span></=
div></div></div></div><br></div></div></div></blockquote></div>

--0000000000009193ee062df71f5a--