axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sagara Gunathunga <sagara.gunathu...@gmail.com>
Subject Re: [jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2
Date Thu, 03 May 2012 06:22:51 GMT
On Thu, May 3, 2012 at 2:38 AM, Andreas Veithen (JIRA) <jira@apache.org>wrote:

>
>    [
> https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13266909#comment-13266909]
>
> Andreas Veithen commented on AXIS2-5158:
> ----------------------------------------
>
> The code in Axis2 trunk now fully supports both Badgerfish and mapped
> JSON. This works out of the box with data bindings, including POJO services.
>
> To use mapped JSON, add a xmlToJsonNamespaceMap parameter to the service
> configuration to define the mappings between XML and JSON namespaces, as
> shown in the following sample:
>
> <service name="POJOService" scope="application" targetNamespace="
> http://example.org">
>    <description>POJO Service</description>
>    <schema schemaNamespace="http://example.org"/>
>    <messageReceivers>
>        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
> class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"/>
>        <messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
> class="org.apache.axis2.rpc.receivers.RPCMessageReceiver"/>
>    </messageReceivers>
>    <parameter
> name="ServiceClass">org.apache.axis2.json.POJOService</parameter>
>    <parameter name="xmlToJsonNamespaceMap">
>        <mapping xmlNamespace="http://example.org" jsonNamespace=""/>
>    </parameter>
> </service>
>
> There are a couple more things to be done before the issue can be closed:
> * Add/update documentation.
> * The new JSON code relies on the feature introduced by AXIOM-399, but
> that feature doesn't interact in an optimal way with the optimizations
> described in AXIOM-282.
> * Check that the feature can be used with Synapse (and maybe add a new
> sample).
>

 Andreas,

In my POV one clear working sample is better than thousand words, it would
be helpful if you can add a Axis2 sample to demonstrate above JSON
improvements. I don't think what ever the existing samples don't not
reflects Axis2 JSON support clearly.

Thanks !




>
> > Improve JSON support in Axis2
> > -----------------------------
> >
> >                 Key: AXIS2-5158
> >                 URL: https://issues.apache.org/jira/browse/AXIS2-5158
> >             Project: Axis2
> >          Issue Type: Improvement
> >          Components: json
> >    Affects Versions: 1.6.1
> >            Reporter: Paul Hodchenkov
> >            Assignee: Andreas Veithen
> >         Attachments: AbstractJSONBuilder.java,
> AbstractJSONMessageFormatter.java, ExtendedMappedXMLStreamWriter.java,
> JSONBadgerfishBuilder.java, JSONBadgerfishMessageFormatter.java,
> JSONMappedBuilder.java, JSONMessageFormatter.java
> >
> >
> > RawXMLInOutMessageReceiver can be only used in JSON services now [1].
> > However, JSON/badgerfish builder can be improved by handling
> RPCMessageReceiver correctly. I can't attach the patch because i have copy
> pasted and created my own formatters and builders(please find the source
> attached):
> > 1) It is possible to solve the namespace problem described at [1] by
> explicitly converting JSON/badgerfish to SOAP in JSONbadgerfish builder :
> > public OMElement processDocument(InputStream inputStream, String
> contentType,
> > MessageContext messageContext) throws AxisFault {
> > ....
> > AbstractXMLInputFactory inputFactory = new BadgerFishXMLInputFactory();
> > XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(
> > new JSONTokener(IOUtils.toString(reader)));
> > OMNodeEx document = (OMNodeEx) new
> StAXOMBuilder(xmlReader).getDocumentElement();
> > //removing parent
> > document.setParent(null);
> > //wrapping document with envelope
> > SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
> > SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
> > SOAPBody body = soapEnvelope.getBody();
> > body.addChild(document);
> > soapEnvelope.build();
> >  //converting xml structure to soap xml structure,
> > //this operation will construct SoapEnvelope,SoapBody,SoapFault instead
> of
> > //regular OmElement
> > StAXSOAPModelBuilder stAXSOAPModelBuilder = new
> StAXSOAPModelBuilder(soapEnvelope.getXMLStreamReader(), null);
> > return stAXSOAPModelBuilder.getSOAPEnvelope();
> > ...
> > }
> > 2) jettison 1.2 has cool feature called setIgnoreNamespaces which allows
> to use json formatter with any xml.
> > We use the these builders and formatters successfully with
> JSON/badgerfish request and JSON response.
> > [1] http://isurues.wordpress.com/2009/10/06/how-to-use-axis2-json/
>
> --
> This message is automatically generated by JIRA.
> If you think it was sent incorrectly, please contact your JIRA
> administrators:
> https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
> For more information on JIRA, see: http://www.atlassian.com/software/jira
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-dev-help@axis.apache.org
>
>


-- 
Sagara Gunathunga

Blog      - http://ssagara.blogspot.com
Web      - http://people.apache.org/~sagara/
LinkedIn - http://www.linkedin.com/in/ssagara

Mime
View raw message