Re: moshi.JSONBuilder not building SOAP body from JSON

robertlazarski <[email protected]> Wed, 12 Feb 2025 09:52:36 -1000
Newsgroups gmane.text.xml.axis.user
Message-ID <CABpPLBV-+bCZfRjXnu=gCDH0_cKS6yQNKTYiscGtYV4+Bsu9hQ@mail.gmail.com>
--00000000000031f676062df749e7
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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

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
> 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 requiremen=
t.
> This guide has been updated in our Axis2 GitHub repo.
>
> https://axis.apache.org/axis2/java/core/docs/json-springboot-userguide.ht=
ml
>
> 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 clien=
ts.
>>
>> I'm doing feasibility checks for mapped JSON using the StockQuoteService
>> from samples.quickstartadb in axis-1.8.2 (as described in JSON support i=
n
>> 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.axi=
s2.json.moshi.JsonBuilder"
>> />
>>
>> SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
>>   <soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelop=
e/
>> "/>
>>
>> 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()" becau=
se
>> "param" is null"
>>
>> What am I missing? Can the moshi.JSONBuilder not be used for mapped JSON
>> with ADB?
>>
>>
>>
>>
>>

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

<div dir=3D"ltr">For SOAP in your example, it is a different implementation=
. The user guide link is pure JSON without SOAP at all. <br></div><br><div =
class=3D"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail=
_attr">On Wed, Feb 12, 2025 at 9:40=E2=80=AFAM robertlazarski &lt;<a href=
=3D"mailto:[email protected]">[email protected]</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-left:1ex"><div dir=3D"lt=
r"><div>I use Moshi with Axis2 quite a bit at my day job, and the 2.0.0 rel=
ease 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 user guide for M=
oshi. 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.=
 <br></div><div><br></div><div><a href=3D"https://axis.apache.org/axis2/jav=
a/core/docs/json-springboot-userguide.html" target=3D"_blank">https://axis.=
apache.org/axis2/java/core/docs/json-springboot-userguide.html</a></div><di=
v><br></div><div>My best guess on your problem is an axis2.xml issue someho=
w, so a glance at the user guide axis2.xml is my suggestion. Also, the clie=
nt needs that JSoN syntax. <br></div><div><br></div><div>Let us know if you=
 still need help. <br></div><div><br></div><div><br></div></div><br><div cl=
ass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Feb 12, 2=
025 at 12:45=E2=80=AFAM Stefan Traud &lt;[email protected]&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><di=
v style=3D"font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:=
13px"><div dir=3D"ltr">We are investigating to enhance our running axis2 se=
rvice with JSON support, i.e. to use JSON over SOAP to facilitate support n=
on-java clients.</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">I&#39;m d=
oing feasibility checks for mapped JSON using the StockQuoteService from sa=
mples.quickstartadb in axis-1.8.2 (as described in JSON support in Axis2 tu=
torial)</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">With the JSONOMBui=
lder 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:rg=
b(0,0,0);font-family:Consolas;font-size:10pt"><div style=3D"margin:0px">&lt=
;messageBuilder contentType=3D&quot;application/<span style=3D"text-decorat=
ion-line:underline;text-decoration-color:rgb(255,128,64);text-decoration-st=
yle:wavy">json</span>&quot;=C2=A0<span style=3D"font-size:10pt">class=3D&qu=
ot;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,sans-serif">JSON =
message for operation &#39;getPrice&#39;:=C2=A0<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)">{&quot;getPrice&quot;:{&quo=
t;symbol&quot;:&quot;IBM&quot;}}</span></span></span></span></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 Neu=
e&quot;,Helvetica,Arial,sans-serif"><span><span style=3D"padding:0px 0px 0p=
x 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:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size=
:13.3333px">SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusine=
ssLogic:<br>=C2=A0<span><span style=3D"padding:0px 0px 0px 2px"><span style=
=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt">&lt;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.samples/xsd" target=
=3D"_blank">http://quickstart.samples/xsd</a>&quot;&gt;&lt;symbol&gt;IBM&lt=
;/symbol&gt;&lt;/getPrice&gt;&lt;/soapenv:Body&gt;</span></span></span></sp=
an></span></span></span></span></span></span></span></span></div><div style=
=3D"margin:0px" dir=3D"ltr"><span style=3D"font-size:10pt"><span><span styl=
e=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Aria=
l,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:&quot;Helv=
etica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px"><span><spa=
n style=3D"padding:0px 0px 0px 2px"><span style=3D"color:rgb(0,0,0);font-fa=
mily: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:&qu=
ot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif">However when I switch t=
o 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-family:Consolas;font-s=
ize:10pt"><div style=3D"margin:0px" 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;messageBuilder contentType=3D&quot=
;application/<span style=3D"text-decoration-line:underline;text-decoration-=
color:rgb(255,128,64);text-decoration-style:wavy">json</span>&quot;=C2=A0<s=
pan style=3D"font-size:10pt">class=3D&quot;org.apache.axis2.json.moshi.Json=
Builder&quot; /&gt;</span></div><div style=3D"margin:0px"><span style=3D"fo=
nt-size:10pt"><br></span></div><div style=3D"margin:0px" dir=3D"ltr"><div d=
ir=3D"ltr"><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue=
&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px">SOAP body in StockQu=
oteServiceMessageReceiverInOut.invokeBusinessLogic:</span><br style=3D"colo=
r:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-se=
rif;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"><span style=3D"color:=
rgb(0,0,0);font-family:Consolas;font-size:10pt">&lt;soapenv:Body xmlns:soap=
env=3D&quot;<a href=3D"http://schemas.xmlsoap.org/soap/envelope/" target=3D=
"_blank">http://schemas.xmlsoap.org/soap/envelope/</a>&quot;/&gt;</span></s=
pan></span></div><div dir=3D"ltr"><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></div><div dir=3D"ltr"><span><span style=3D"color:r=
gb(0,0,0);font-family:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif=
;font-size:13.3333px">Getting the wrapped param with fromOM will then fail =
in<br></span></span><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">fromOM(</p><p style=3D"margin:0px">                      <span style=
=3D"color:rgb(106,62,62)">msgContext</span>.getEnvelope().getBody().getFirs=
tElement(),</p><p style=3D"margin:0px">                      samples.quicks=
tart.service.adb.xsd.GetPrice.<span style=3D"color:rgb(127,0,85);font-weigh=
t:bold">class</span>);</p></div></div></div><br></div><div dir=3D"ltr"><spa=
n><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,He=
lvetica,Arial,sans-serif;font-size:13.3333px">with AxisFault &quot;<span><s=
pan 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.apache.axiom.om.OME=
lement.getXMLStreamReaderWithoutCaching()&quot; because &quot;param&quot; i=
s 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;Helvetica Neue&quot;=
,Helvetica,Arial,sans-serif;font-size:13.3333px"><br></span></span></div><d=
iv dir=3D"ltr"><span><span style=3D"color:rgb(0,0,0);font-family:&quot;Helv=
etica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333px"><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">What am I missing? Can the moshi.JS=
ONBuilder not be used for mapped JSON with ADB?</span></span><br></span></s=
pan></div></div></div></div></div><br></div></div></div></div></div><br></d=
iv><div style=3D"margin:0px" dir=3D"ltr"><span style=3D"font-size:10pt"><sp=
an><span style=3D"color:rgb(0,0,0);font-family:&quot;Helvetica Neue&quot;,H=
elvetica,Arial,sans-serif"><span><span style=3D"padding:0px 0px 0px 2px"><s=
pan style=3D"color:rgb(0,0,0);font-family:Consolas;font-size:10pt"><span st=
yle=3D"color:rgb(42,0,255)"><span><span style=3D"color:rgb(0,0,0);font-fami=
ly:&quot;Helvetica Neue&quot;,Helvetica,Arial,sans-serif;font-size:13.3333p=
x"><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></div><=
/div><br></div></div></div></blockquote></div>
</blockquote></div>

--00000000000031f676062df749e7--