Re: moshi.JSONBuilder not building SOAP body from JSON

Stefan Traud <[email protected]> Fri, 14 Feb 2025 10:58:33 +0000 (UTC)
Newsgroups gmane.text.xml.axis.user
Message-ID <[email protected]>
------=_Part_131066_1284248910.1739530713820
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 Thanks a lot for your support!=C2=A0You are absolutely right, the axis2.xm=
l required additional modifications. I was somehow assuming that I can just=
 replace the JSONOM builder and formatter with the ones from moshi, but the=
re is obviously more to it as described in the "New JSON support in Apache =
Axis2".=C2=A0
I followed the configuration steps for the XML Stream API Base Approach as =
described in=C2=A0Apache Axis2 =E2=80=93 How to configure Native approach a=
nd XML Stream API base approach, using moshi instead of gson. I can now run=
 the samples.quickstartadb service using json messages with moshi support -=
 cool!
I will now try to apply the learnings in our webservice project.


    Am Mittwoch, 12. Februar 2025 um 20:56:56 MEZ hat robertlazarski <rober=
[email protected]> Folgendes geschrieben: =20
=20
 See the code differences between org.apache.axis2.json.JSONOMBuilder and o=
rg.apache.axis2.json.moshi.JsonBuilder, the coding isn't too complicated.=
=C2=A0
I suggest creating a Jira issue, and if up to it coding a GitHub PR. I can =
help with the coding if you need it, and can test it.=20

On Wed, Feb 12, 2025 at 9:52=E2=80=AFAM robertlazarski <robertlazarski@gmai=
l.com> wrote:

For SOAP in your example, it is a different implementation. The user guide =
link is pure JSON without SOAP at all.=20

On Wed, Feb 12, 2025 at 9:40=E2=80=AFAM robertlazarski <robertlazarski@gmai=
l.com> wrote:

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

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.=20

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 JSo=
N syntax.=20

Let us know if you still need help.=20



On Wed, Feb 12, 2025 at 12:45=E2=80=AFAM Stefan Traud <[email protected]=
om.invalid> 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 clients.
I'm doing feasibility checks for mapped JSON using the StockQuoteService fr=
om samples.quickstartadb in axis-1.8.2 (as described in JSON support in Axi=
s2 tutorial)
With the JSONOMBuilder this works as expected:axis2.xml:<messageBuilder con=
tentType=3D"application/json"=C2=A0class=3D"org.apache.axis2.json.JSONOMBui=
lder"/>
JSON message for operation 'getPrice':=C2=A0{"getPrice":{"symbol":"IBM"}}SO=
AP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
=C2=A0<soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelo=
pe/"><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"=C2=A0class=3D"=
org.apache.axis2.json.moshi.JsonBuilder" />
SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
=C2=A0 <soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envel=
ope/"/>
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.getXMLStreamRe=
aderWithoutCaching()" because "param" is null"

What am I missing? Can the moshi.JSONBuilder not be used for mapped JSON wi=
th ADB?







 =20
------=_Part_131066_1284248910.1739530713820
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp27ddead5yahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false">Thanks a lot for your suppor=
t!&nbsp;</div><div dir=3D"ltr" data-setdir=3D"false">You are absolutely rig=
ht, the axis2.xml required additional modifications. I was somehow assuming=
 that I can just replace the JSONOM builder and formatter with the ones fro=
m moshi, but there is obviously more to it as described in the "New JSON su=
pport in Apache Axis2".&nbsp;</div><div dir=3D"ltr" data-setdir=3D"false"><=
br></div><div dir=3D"ltr" data-setdir=3D"false">I followed the configuratio=
n steps for the <span>XML Stream API Base Approach as described in&nbsp;<sp=
an><a href=3D"https://axis.apache.org/axis2/java/core/docs/json_gson_user_g=
uide.html" rel=3D"nofollow" target=3D"_blank">Apache Axis2 =E2=80=93 How to=
 configure Native approach and XML Stream API base approach</a>, using mosh=
i instead of gson. I can now run the samples.quickstartadb service using js=
on messages with moshi support - cool!</span></span></div><div dir=3D"ltr" =
data-setdir=3D"false"><span><span><br></span></span></div><div dir=3D"ltr" =
data-setdir=3D"false"><span><span>I will now try to apply the learnings in =
our webservice project.</span></span></div><div dir=3D"ltr" data-setdir=3D"=
false"><br></div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div><br>=
</div>
       =20
        </div><div id=3D"ydpf4faf63yahoo_quoted_9895732648" class=3D"ydpf4f=
af63yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        Am Mittwoch, 12. Februar 2025 um 20:56:56 MEZ hat r=
obertlazarski &lt;[email protected]&gt; Folgendes geschrieben:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div><div id=3D"ydpf4faf63yiv1118137976"><div><div dir=3D"l=
tr"><div>See the code differences between <span style=3D"font-size:10pt;">o=
rg.apache.axis2.json.JSONOMBuilder and </span><span style=3D"font-size:10pt=
;">org.apache.axis2.json.moshi.JsonBuilder, the coding isn't too complicate=
d.&nbsp;</span></div><div><span style=3D"font-size:10pt;"><br clear=3D"none=
"></span></div><div>I suggest creating a Jira issue, and if up to it coding=
 a GitHub PR. I can help with the coding if you need it, and can test it. <=
br clear=3D"none"></div></div><br clear=3D"none"><div id=3D"ydpf4faf63yiv11=
18137976yqt20730" class=3D"ydpf4faf63yiv1118137976yqt8742540749"><div class=
=3D"ydpf4faf63yiv1118137976gmail_quote ydpf4faf63yiv1118137976gmail_quote_c=
ontainer"><div dir=3D"ltr" class=3D"ydpf4faf63yiv1118137976gmail_attr">On W=
ed, Feb 12, 2025 at 9:52=E2=80=AFAM robertlazarski &lt;<a shape=3D"rect" hr=
ef=3D"mailto:[email protected]" rel=3D"nofollow" target=3D"_blank">r=
[email protected]</a>&gt; wrote:<br clear=3D"none"></div><blockquote =
style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa=
dding-left:1ex;" class=3D"ydpf4faf63yiv1118137976gmail_quote"><div dir=3D"l=
tr">For SOAP in your example, it is a different implementation. The user gu=
ide link is pure JSON without SOAP at all. <br clear=3D"none"></div><br cle=
ar=3D"none"><div class=3D"ydpf4faf63yiv1118137976gmail_quote"><div dir=3D"l=
tr" class=3D"ydpf4faf63yiv1118137976gmail_attr">On Wed, Feb 12, 2025 at 9:4=
0=E2=80=AFAM robertlazarski &lt;<a shape=3D"rect" href=3D"mailto:robertlaza=
[email protected]" rel=3D"nofollow" target=3D"_blank">[email protected]=
</a>&gt; 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;" class=
=3D"ydpf4faf63yiv1118137976gmail_quote"><div dir=3D"ltr"><div>I use Moshi w=
ith 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 clear=3D"none"></div=
><div><br clear=3D"none"></div><div>For 1.8.2 we have samples and a user gu=
ide for Moshi. It is based on Spring Boot but that is just for demonstratio=
n and it is not a requirement. This guide has been updated in our Axis2 Git=
Hub repo. <br clear=3D"none"></div><div><br clear=3D"none"></div><div><a sh=
ape=3D"rect" href=3D"https://axis.apache.org/axis2/java/core/docs/json-spri=
ngboot-userguide.html" rel=3D"nofollow" target=3D"_blank">https://axis.apac=
he.org/axis2/java/core/docs/json-springboot-userguide.html</a></div><div><b=
r clear=3D"none"></div><div>My best guess on your problem is an axis2.xml i=
ssue somehow, so a glance at the user guide axis2.xml is my suggestion. Als=
o, the client needs that JSoN syntax. <br clear=3D"none"></div><div><br cle=
ar=3D"none"></div><div>Let us know if you still need help. <br clear=3D"non=
e"></div><div><br clear=3D"none"></div><div><br clear=3D"none"></div></div>=
<br clear=3D"none"><div class=3D"ydpf4faf63yiv1118137976gmail_quote"><div d=
ir=3D"ltr" class=3D"ydpf4faf63yiv1118137976gmail_attr">On Wed, Feb 12, 2025=
 at 12:45=E2=80=AFAM Stefan Traud &lt;[email protected]&gt; wr=
ote:<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;" class=3D"ydpf4faf=
63yiv1118137976gmail_quote"><div><div style=3D"font-family:Helvetica Neue, =
Helvetica, Arial, sans-serif;font-size:13px;"><div dir=3D"ltr">We are inves=
tigating to enhance our running axis2 service with JSON support, i.e. to us=
e JSON over SOAP to facilitate support non-java clients.</div><div dir=3D"l=
tr"><br clear=3D"none"></div><div dir=3D"ltr">I'm doing feasibility checks =
for mapped JSON using the StockQuoteService from samples.quickstartadb in a=
xis-1.8.2 (as described in JSON support in Axis2 tutorial)</div><div dir=3D=
"ltr"><br clear=3D"none"></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;"><div style=3D"color:rgb(0,0,0)=
;font-family:Consolas;font-size:10pt;"><div style=3D"margin:0px;">&lt;messa=
geBuilder contentType=3D"application/<span style=3D"text-decoration-line:un=
derline;text-decoration-color:rgb(255,128,64);text-decoration-style:wavy;">=
json</span>"&nbsp;<span style=3D"font-size:10pt;">class=3D"org.apache.axis2=
.json.JSONOMBuilder"/&gt;</span></div><div dir=3D"ltr" style=3D"margin:0px;=
"><span style=3D"font-size:10pt;"><span><span style=3D"color:rgb(0,0,0);fon=
t-family:Helvetica, Arial, sans-serif;"><br clear=3D"none"></span></span></=
span></div><div dir=3D"ltr" style=3D"margin:0px;"><span style=3D"font-size:=
10pt;"><span><span style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, =
sans-serif;">JSON message for operation 'getPrice':&nbsp;<span><span style=
=3D"padding:0px 0px 0px 2px;"><span style=3D"color:rgb(0,0,0);font-family:C=
onsolas;font-size:10pt;"><span style=3D"color:rgb(42,0,255);">{"getPrice":{=
"symbol":"IBM"}}</span></span></span></span></span></span></span></div><div=
 dir=3D"ltr" style=3D"margin:0px;"><span style=3D"font-size:10pt;"><span><s=
pan style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-serif;"><s=
pan><span style=3D"padding: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"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-=
serif;font-size:13.3333px;">SOAP body in StockQuoteServiceMessageReceiverIn=
Out.invokeBusinessLogic:<br clear=3D"none">&nbsp;<span><span style=3D"paddi=
ng:0px 0px 0px 2px;"><span style=3D"color:rgb(0,0,0);font-family:Consolas;f=
ont-size:10pt;">&lt;soapenv:Body xmlns:soapenv=3D"<a shape=3D"rect" href=3D=
"http://schemas.xmlsoap.org/soap/envelope/" rel=3D"nofollow" target=3D"_bla=
nk">http://schemas.xmlsoap.org/soap/envelope/</a>"&gt;&lt;getPrice xmlns=3D=
"<a shape=3D"rect" href=3D"http://quickstart.samples/xsd" rel=3D"nofollow" =
target=3D"_blank">http://quickstart.samples/xsd</a>"&gt;&lt;symbol&gt;IBM&l=
t;/symbol&gt;&lt;/getPrice&gt;&lt;/soapenv:Body&gt;</span></span></span></s=
pan></span></span></span></span></span></span></span></span></div><div dir=
=3D"ltr" style=3D"margin:0px;"><span style=3D"font-size:10pt;"><span><span =
style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-serif;"><span>=
<span style=3D"padding:0px 0px 0px 2px;"><span style=3D"color:rgb(0,0,0);fo=
nt-family:Consolas;font-size:10pt;"><span style=3D"color:rgb(42,0,255);"><s=
pan><span style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-seri=
f;font-size:13.3333px;"><span><span style=3D"padding:0px 0px 0px 2px;"><spa=
n style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt;"><br clear=
=3D"none"></span></span></span></span></span></span></span></span></span></=
span></span></span></div><div dir=3D"ltr" style=3D"margin:0px;"><div><div d=
ir=3D"ltr" style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-ser=
if;">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:Helvetic=
a, Arial, sans-serif;">axis2.xml:</div><div dir=3D"ltr" style=3D"color:rgb(=
0,0,0);font-family:Helvetica, Arial, sans-serif;"><div style=3D"padding:0px=
 0px 0px 2px;"><div style=3D"font-family:Consolas;font-size:10pt;"><div dir=
=3D"ltr" style=3D"margin:0px;"> <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;">&lt;messageBuilder contentType=3D"application/<span =
style=3D"text-decoration-line:underline;text-decoration-color:rgb(255,128,6=
4);text-decoration-style:wavy;">json</span>"&nbsp;<span style=3D"font-size:=
10pt;">class=3D"org.apache.axis2.json.moshi.JsonBuilder" /&gt;</span></div>=
<div style=3D"margin:0px;"><span style=3D"font-size:10pt;"><br clear=3D"non=
e"></span></div><div dir=3D"ltr" style=3D"margin:0px;"><div dir=3D"ltr"><sp=
an style=3D"color:rgb(0,0,0);font-family:Helvetica, Arial, sans-serif;font-=
size:13.3333px;">SOAP body in StockQuoteServiceMessageReceiverInOut.invokeB=
usinessLogic:</span><br clear=3D"none" style=3D"color:rgb(0,0,0);font-famil=
y:Helvetica, Arial, sans-serif;font-size:13.3333px;"><span style=3D"color:r=
gb(0,0,0);font-family:Helvetica, Arial, sans-serif;font-size:13.3333px;">&n=
bsp;</span> <span><span style=3D"padding:0px 0px 0px 2px;"><span style=3D"c=
olor:rgb(0,0,0);font-family:Consolas;font-size:10pt;">&lt;soapenv:Body xmln=
s:soapenv=3D"<a shape=3D"rect" href=3D"http://schemas.xmlsoap.org/soap/enve=
lope/" rel=3D"nofollow" target=3D"_blank">http://schemas.xmlsoap.org/soap/e=
nvelope/</a>"/&gt;</span></span></span></div><div dir=3D"ltr"><span><span s=
tyle=3D"padding:0px 0px 0px 2px;"><span style=3D"color:rgb(0,0,0);font-fami=
ly:Consolas;font-size:10pt;"><br clear=3D"none"></span></span></span></div>=
<div dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family:Helvetic=
a, Arial, sans-serif;font-size:13.3333px;">Getting the wrapped param with f=
romOM will then fail in<br clear=3D"none"></span></span><div><div style=3D"=
padding:0px 0px 0px 2px;"><div style=3D"color:rgb(0,0,0);font-family:Consol=
as;font-size:10pt;"><p style=3D"margin:0px;">fromOM(</p><p style=3D"margin:=
0px;">                      <span style=3D"color:rgb(106,62,62);">msgContex=
t</span>.getEnvelope().getBody().getFirstElement(),</p><p style=3D"margin:0=
px;">                      samples.quickstart.service.adb.xsd.GetPrice.<spa=
n style=3D"color:rgb(127,0,85);font-weight:bold;">class</span>);</p></div><=
/div></div><br clear=3D"none"></div><div dir=3D"ltr"><span><span style=3D"c=
olor:rgb(0,0,0);font-family:Helvetica, Arial, sans-serif;font-size:13.3333p=
x;">with AxisFault "<span><span style=3D"padding:0px 0px 0px 2px;"><span st=
yle=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt;">Cannot invoke=
 "org.apache.axiom.om.OMElement.getXMLStreamReaderWithoutCaching()" because=
 "param" is null</span></span></span>"</span></span><br clear=3D"none"></di=
v><div dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family:Helvet=
ica, Arial, sans-serif;font-size:13.3333px;"><br clear=3D"none"></span></sp=
an></div><div dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family=
:Helvetica, Arial, sans-serif;font-size:13.3333px;"><span><span style=3D"co=
lor:rgb(0,0,0);font-family: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></span><br clear=3D"none"></span></span></div></div></div>=
</div></div><br clear=3D"none"></div></div></div></div></div><br clear=3D"n=
one"></div><div dir=3D"ltr" style=3D"margin:0px;"><span style=3D"font-size:=
10pt;"><span><span style=3D"color:rgb(0,0,0);font-family: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 style=3D"color=
:rgb(42,0,255);"><span><span style=3D"color:rgb(0,0,0);font-family:Helvetic=
a, Arial, sans-serif;font-size:13.3333px;"><span><span style=3D"padding:0px=
 0px 0px 2px;"><span style=3D"color:rgb(0,0,0);font-family:Consolas;font-si=
ze:10pt;"><br clear=3D"none"></span></span></span></span></span></span></sp=
an></span></span></span></span></span></div></div></div></div><br clear=3D"=
none"></div></div></div></blockquote></div>
</blockquote></div>
</blockquote></div></div>
</div></div></div>
            </div>
        </div></body></html>
------=_Part_131066_1284248910.1739530713820--