Thanks a lot for your support! You are absolutely right, the axis2.xml 
required additional modifications. I was somehow assuming that I can just 
replace the JSONOM builder and formatter with the ones from moshi, but there is 
obviously more to it as described in the "New JSON support in Apache Axis2". 
I followed the configuration steps for the XML Stream API Base Approach as 
described in Apache Axis2 – How to configure Native approach and 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 
<robertlazar...@gmail.com> Folgendes geschrieben:  
 
 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 AM robertlazarski <robertlazar...@gmail.com> wrote:

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 AM robertlazarski <robertlazar...@gmail.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 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 AM Stefan Traud <stefan_tr...@yahoo.com.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 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="application/json" class="org.apache.axis2.json.JSONOMBuilder"/>
JSON message for operation 'getPrice': {"getPrice":{"symbol":"IBM"}}SOAP body 
in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
 <soapenv:Body 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><getPrice 
xmlns="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="application/json" 
class="org.apache.axis2.json.moshi.JsonBuilder" />
SOAP body in StockQuoteServiceMessageReceiverInOut.invokeBusinessLogic:
  <soapenv:Body xmlns:soapenv="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()" because 
"param" is null"

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







  

Reply via email to