Re: moshi.JSONBuilder not building SOAP body from JSON
robertlazarski <[email protected]> Wed, 12 Feb 2025 09:56:33 -1000
| Newsgroups | gmane.text.xml.axis.user |
|---|---|
| Message-ID | <CABpPLBWL2Sjz-eX6OOLJRjQsM_pHzFf6ec3Mj8u0iMCxMRqi6g@mail.gmail.com> |
--0000000000005bfea2062df7570e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable See the code differences between org.apache.axis2.json.JSONOMBuilder and org.apache.axis2.json.moshi.JsonBuilder, the coding isn't too complicated. 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. 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 guid= e > link is pure JSON without SOAP at all. > > On Wed, Feb 12, 2025 at 9:40=E2=80=AFAM robertlazarski <robertlazarski@gm= ail.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 requireme= nt. >> This guide has been updated in our Axis2 GitHub repo. >> >> >> https://axis.apache.org/axis2/java/core/docs/json-springboot-userguide.h= tml >> >> 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 tha= t >> 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 clie= nts. >>> >>> I'm doing feasibility checks for mapped JSON using the StockQuoteServic= e >>> 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/envelop= e/"><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.ax= is2.json.moshi.JsonBuilder" >>> /> >>> >>> SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic: >>> <soapenv:Body xmlns:soapenv=3D"http://schemas.xmlsoap.org/soap/envelo= pe/ >>> "/> >>> >>> 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()" beca= use >>> "param" is null" >>> >>> What am I missing? Can the moshi.JSONBuilder not be used for mapped JSO= N >>> with ADB? >>> >>> >>> >>> >>> --0000000000005bfea2062df7570e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>See the code differences between <span style=3D"font-= size:10pt">org.apache.axis2.json.JSONOMBuilder and </span><span style=3D"fo= nt-size:10pt">org.apache.axis2.json.moshi.JsonBuilder, the coding isn't= too complicated.=C2=A0</span></div><div><span style=3D"font-size:10pt"><br= ></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. <b= r></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 9:52=E2=80=AFAM rober= tlazarski <<a href=3D"mailto:[email protected]">robertlazarski@gm= ail.com</a>> 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 dir=3D"ltr">For SOAP in your example, it is a different impleme= ntation. The user guide link is pure JSON without SOAP at all. <br></div><b= r><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, = Feb 12, 2025 at 9:40=E2=80=AFAM robertlazarski <<a href=3D"mailto:robert= [email protected]" target=3D"_blank">[email protected]</a>> wrot= e:<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"l= tr"><div>I use Moshi with Axis2 quite a bit at my day job, and the 2.0.0 re= lease that is about to go out very soon has improved this area of Axis2. <b= r></div><div><br></div><div>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= . <br></div><div><br></div><div><a href=3D"https://axis.apache.org/axis2/ja= va/core/docs/json-springboot-userguide.html" target=3D"_blank">https://axis= .apache.org/axis2/java/core/docs/json-springboot-userguide.html</a></div><d= iv><br></div><div>My best guess on your problem is an axis2.xml issue someh= ow, so a glance at the user guide axis2.xml is my suggestion. Also, the cli= ent needs that JSoN syntax. <br></div><div><br></div><div>Let us know if yo= u still need help. <br></div><div><br></div><div><br></div></div><br><div c= lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, Feb 12, = 2025 at 12:45=E2=80=AFAM Stefan Traud <[email protected]>= ; 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><d= iv 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 s= ervice with JSON support, i.e. to use JSON over SOAP to facilitate support = non-java clients.</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">I'm = doing feasibility checks for mapped JSON using the StockQuoteService from s= amples.quickstartadb in axis-1.8.2 (as described in JSON support in Axis2 t= utorial)</div><div dir=3D"ltr"><br></div><div dir=3D"ltr">With the JSONOMBu= ilder this works as expected:</div><div dir=3D"ltr">axis2.xml:</div><div di= r=3D"ltr"><div><div style=3D"padding:0px 0px 0px 2px"><div style=3D"color:r= gb(0,0,0);font-family:Consolas;font-size:10pt"><div style=3D"margin:0px">&l= t;messageBuilder contentType=3D"application/<span style=3D"text-decora= tion-line:underline;text-decoration-color:rgb(255,128,64);text-decoration-s= tyle:wavy">json</span>"=C2=A0<span style=3D"font-size:10pt">class=3D&q= uot;org.apache.axis2.json.JSONOMBuilder"/></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:"Helvetica Neue",Helvetica,Aria= l,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:"Helvetica Neue",Helvetica,Arial,sans-serif">JSON = message for operation 'getPrice':=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)">{"getPrice":{&quo= t;symbol":"IBM"}}</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:"Helvetica Neu= e",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:"Helvetica Neue",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"><soapenv:Body = xmlns:soapenv=3D"<a href=3D"http://schemas.xmlsoap.org/soap/envelope/"= target=3D"_blank">http://schemas.xmlsoap.org/soap/envelope/</a>">&= lt;getPrice xmlns=3D"<a href=3D"http://quickstart.samples/xsd" target= =3D"_blank">http://quickstart.samples/xsd</a>"><symbol>IBM<= ;/symbol></getPrice></soapenv:Body></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:"Helvetica Neue",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:"Helv= etica Neue",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",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:"Helvetica Neue",Helvetica= ,Arial,sans-serif">axis2.xml:</div><div dir=3D"ltr" style=3D"color:rgb(0,0,= 0);font-family:"Helvetica Neue",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"><messageBuilder contentType=3D"= ;application/<span style=3D"text-decoration-line:underline;text-decoration-= color:rgb(255,128,64);text-decoration-style:wavy">json</span>"=C2=A0<s= pan style=3D"font-size:10pt">class=3D"org.apache.axis2.json.moshi.Json= Builder" /></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:"Helvetica Neue= ",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:"Helvetica Neue",Helvetica,Arial,sans-se= rif;font-size:13.3333px"><span style=3D"color:rgb(0,0,0);font-family:"= Helvetica Neue",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"><soapenv:Body xmlns:soap= env=3D"<a href=3D"http://schemas.xmlsoap.org/soap/envelope/" target=3D= "_blank">http://schemas.xmlsoap.org/soap/envelope/</a>"/></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:"Helvetica Neue",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:"Helvetica Neue",He= lvetica,Arial,sans-serif;font-size:13.3333px">with AxisFault "<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 "org.apache.axiom.om.OME= lement.getXMLStreamReaderWithoutCaching()" because "param" i= s null</span></span></span>"</span></span><br></div><div dir=3D"ltr"><= span><span style=3D"color:rgb(0,0,0);font-family:"Helvetica Neue"= ,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:"Helv= etica Neue",Helvetica,Arial,sans-serif;font-size:13.3333px"><span><spa= n style=3D"color:rgb(0,0,0);font-family:"Helvetica Neue",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:"Helvetica Neue",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:"Helvetica Neue",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> </blockquote></div> --0000000000005bfea2062df7570e--