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