You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Paul Hodchenkov (Created) (JIRA)" <ji...@apache.org> on 2011/10/03 09:08:34 UTC

[jira] [Created] (AXIS2-5158) Improve JSON support in Axis2

Improve JSON support in Axis2
-----------------------------

                 Key: AXIS2-5158
                 URL: https://issues.apache.org/jira/browse/AXIS2-5158
             Project: Axis2
          Issue Type: Improvement
          Components: databinding
    Affects Versions: 1.6.1
            Reporter: Paul Hodchenkov


RawXMLInOutMessageReceiver can be only used for JSON services for 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 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 pure 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


Re: [jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by Sagara Gunathunga <sa...@gmail.com>.
On Thu, May 3, 2012 at 2:38 AM, Andreas Veithen (JIRA) <ji...@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

[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150610#comment-13150610 ] 

Paul Hodchenkov commented on AXIS2-5158:
----------------------------------------

Increasing popularity of JSON requires to have more intelligent support for JSON in Axis2 .
We use WSO2 ESB( axis2 is used as core engine) in our environment. One of the requirements was to expose the existing SOAP services over JSON in order to support flex/mobile devices.
The current JSON implementation forces the service to handle payload in a raw way. So the POJO Axis2 services can't expose JSON interfaces(mapped convention) automatically without altering the service. However, after looking to the sources of JSONBadgerfishBuilder i realized that it is possible to handle application/json/badgerfish and application/json request-response scenario if we convert badgerfish to soap in explicit way . 
This allows to:
1) expose existing axis2 services as application/json/badgerfish for requests and application/json for response
2) apply the same mediation rules in WSO2 ESB for both application/json/badgerfish and SOAP requests ( application/json/badgerfish is explicitly converted to SOAP so there is no difference between them)
3) expose json/badgerfish interfaces for non axis2 SOAP services behind the WSO2 ESB

The only problem here is that client should understand badgerfish notation. To provide json interfaces without badgerfish we use xslt transformations inside ESB proxy to enrich json request with the required SOAP namespaces and attributes. so the backend SOAP service will correctly accept such payload. However, this should be done manually for each service operation.
In the ideal situation Axis2 JSON builder should be able(along with ability to use json with POJO service) to fetch the required information from service wsdl(?) and construct SOAP request based on the incoming json request(non badgerfish), so it will provide a cool way to automatically expose JSON services on ESB for any SOAP service.
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
>         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


[jira] [Issue Comment Edited] (AXIS2-5158) Improve JSON support in Axis2

Posted by "PNS (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13151546#comment-13151546 ] 

PNS edited comment on AXIS2-5158 at 11/16/11 9:52 PM:
------------------------------------------------------

Axis2 is too mainstream a technology to not support plain vanilla JSON ("Mapped JSON", if you prefer) and to require workarounds.

It is really surprising that we have reached version 1.6.1 without a permanent, transparent and working solution. From the brief minutes of the Vancouver meeting, there seems to be no intention to resolve in forthcoming releases, either.

The sooner this issue is dealt with, the better.
                
      was (Author: pns):
    Axis2 is too mainstream a technology to not support plain vanilla JSON ("Mapped JSON", if you prefer) and to require workarounds. It is really surprising that we have reached version 1.6.1 without a permanent, transparent and working solution.

The sooner this issue is dealt with, the better.
                  
> 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
>         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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13278960#comment-13278960 ] 

Andreas Veithen commented on AXIS2-5158:
----------------------------------------

Checked that with the latest Axiom code, no exception is thrown anymore inside MessageContext#isFault.
                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13268568#comment-13268568 ] 

Paul Hodchenkov commented on AXIS2-5158:
----------------------------------------

One of the possible minor issues here is that RPCMessageReceiver (at least in axis 2 1.6) is sensitive to the top level arguments order. This produces a problem , if client (especially flex client, which generates json key-value ordered by key's hash ) sends json top level arguments in different order than expected by the method signature. RPCMessageReceiver will try to invoke the service method with shuffled arguments.
                
> 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


[jira] [Updated] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Hodchenkov updated AXIS2-5158:
-----------------------------------

    Attachment: JSONMessageFormatter.java
                JSONMappedBuilder.java
                JSONBadgerfishMessageFormatter.java
                JSONBadgerfishBuilder.java
                ExtendedMappedXMLStreamWriter.java
                AbstractJSONMessageFormatter.java
                AbstractJSONBuilder.java
    
> Improve JSON support in Axis2
> -----------------------------
>
>                 Key: AXIS2-5158
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5158
>             Project: Axis2
>          Issue Type: Improvement
>          Components: databinding
>    Affects Versions: 1.6.1
>            Reporter: Paul Hodchenkov
>         Attachments: AbstractJSONBuilder.java, AbstractJSONMessageFormatter.java, ExtendedMappedXMLStreamWriter.java, JSONBadgerfishBuilder.java, JSONBadgerfishMessageFormatter.java, JSONMappedBuilder.java, JSONMessageFormatter.java
>
>
> RawXMLInOutMessageReceiver can be only used for JSON services for 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 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 pure 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


[jira] [Updated] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Hodchenkov updated AXIS2-5158:
-----------------------------------

    Description: 
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/

  was:
RawXMLInOutMessageReceiver can be only used for JSON services for 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 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 pure JSON response.


[1] http://isurues.wordpress.com/2009/10/06/how-to-use-axis2-json/

    
> 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
>         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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13282022#comment-13282022 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1505 (See [https://builds.apache.org/job/Axis2/1505/])
    AXIS2-5158: Updated the documentation to explain how to configure an Axis2 service for use with Mapped JSON. (Revision 1342071)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml

                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284132#comment-13284132 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1511 (See [https://builds.apache.org/job/Axis2/1511/])
    AXIS2-5158: Updated the documentation with a description of the current architecture. The documentation previously referred to a WSO2 article that is outdated. (Revision 1343015)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml

                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13432186#comment-13432186 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1700 (See [https://builds.apache.org/job/Axis2/1700/])
    AXIS2-5158: Use Parameter#getValue() instead of Parameter#getParameterElement() to get the XML for the xmlToJsonNamespaceMap parameter. This should ensure that the feature can be used in a Synapse proxy. (Revision 1371442)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONUtil.java
* /axis/axis2/java/core/trunk/modules/json/test-repository/services/POJOService.aar/META-INF/services.xml
* /axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml

                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Sagara Gunathunga (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119973#comment-13119973 ] 

Sagara Gunathunga  commented on AXIS2-5158:
-------------------------------------------

Other than above MessageReceiver limitation current JSON support perform number of extra XML/JSON conventions in both client and server sides in order to match with existing Axis2 architecture. The proper solution would be serialize/deserialize  JSON to Java objects and back again directly but this required some refactoring , google-gson [1] can be a good framework for this propose with it's performance and streaming support.

BTW as a short term solution we can include your modification to work with RPCMessageReceivers. It's bit of difficult task to review raw source files instead  can you please provide your modification as a svn patch file for Axis2 trunk.  It Would be great if you can provide a unit test for this too . 

[1] - http://code.google.com/p/google-gson/
                
> 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
>         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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13284152#comment-13284152 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1513 (See [https://builds.apache.org/job/Axis2/1513/])
    AXIS2-5158: Adding a sample to the documentation that shows how to enable JSON on an existing service (the ADB stock quote sample in this case). (Revision 1343034)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/src/site/xdoc/docs/json_support.xml

                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Andreas Veithen (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13150377#comment-13150377 ] 

Andreas Veithen commented on AXIS2-5158:
----------------------------------------

As explained in Isuru's blog, the current implementation constructs an OMSourcedElement so that the original JSON payload can be accessed in scenarios where it is not necessary to convert it to XML. I guess that this is relevant for ESB scenarios where a JSON request is forwarded to an endpoint that accepts JSON. The problem is that Axiom currently requires that the local name and namespace URI is known when constructing the OMSourcedElement. The current JSON implementation is unable to determine this information and that's why the request is not dispatched correctly, which is why it doesn't work with RPCMessageReceiver.

Interestingly nothing would prevent Axiom from supporting OMSourcedElements with unknown local name and namespace URI. The only constraint is that such an OMSourcedElement needs to be automatically expanded when getLocalName(), getNamespace() or getQName() is called (which in the scenario described here would occur during dispatching). Axiom actually already supports this for the namespace prefix which can be determined lazily (see AXIOM-334). It would be natural to extend this concept to the local name and namespace URI.
                
> 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
>         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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
    [ 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).
                
> 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


[jira] [Updated] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul Hodchenkov updated AXIS2-5158:
-----------------------------------

    Component/s:     (was: databinding)
                 json
    
> 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
>         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


[jira] [Assigned] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Andreas Veithen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andreas Veithen reassigned AXIS2-5158:
--------------------------------------

    Assignee: Andreas Veithen
    
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13404871#comment-13404871 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1610 (See [https://builds.apache.org/job/Axis2/1610/])
    AXIS2-5158: SOAPEnvelope#hasFault should normally not throw any exception. (Revision 1355946)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/context/MessageContext.java

                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13265470#comment-13265470 ] 

Hudson commented on AXIS2-5158:
-------------------------------

Integrated in Axis2 #1412 (See [https://builds.apache.org/job/Axis2/1412/])
    Improving the JSON code - Step 2 - Instead of using some hacks to extract the name of the element, just let Axiom determine it lazily using the feature introduced by AXIOM-399.

This should make databindings work with Badgerfish (although we have no integration test for this yet) and solve AXIS2-5158, AXIS2-5295 and AXIS2-5300. (Revision 1332402)

     Result = SUCCESS
veithen : 
Files : 
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/AbstractJSONDataSource.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/AbstractJSONOMBuilder.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONBadgerfishDataSource.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONBadgerfishMessageFormatter.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONBadgerfishOMBuilder.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONDataSource.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONMessageFormatter.java
* /axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/JSONOMBuilder.java
* /axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONDataSourceTest.java
* /axis/axis2/java/core/trunk/modules/json/test/org/apache/axis2/json/JSONOMBuilderTest.java

                
> 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


[jira] [Issue Comment Edited] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Sagara Gunathunga (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13119973#comment-13119973 ] 

Sagara Gunathunga  edited comment on AXIS2-5158 at 10/4/11 9:08 AM:
--------------------------------------------------------------------

Other than above MessageReceiver limitation current JSON support perform number of extra XML/JSON conventions in both client and server sides in order to match with existing Axis2 architecture. The proper solution would be serialize/deserialize  JSON to Java objects and back again directly but this required some refactoring , google-gson [1] can be a good framework for this propose with it's performance and streaming support.

BTW as a short term solution we can include your modification to work with RPCMessageReceivers. BTW it's bit of difficult task to review raw source files instead  can you please provide your modification as a svn patch for Axis2 trunk.  It Would be great if you can provide a unit test for this too . 

[1] - http://code.google.com/p/google-gson/
                
      was (Author: sagara):
    Other than above MessageReceiver limitation current JSON support perform number of extra XML/JSON conventions in both client and server sides in order to match with existing Axis2 architecture. The proper solution would be serialize/deserialize  JSON to Java objects and back again directly but this required some refactoring , google-gson [1] can be a good framework for this propose with it's performance and streaming support.

BTW as a short term solution we can include your modification to work with RPCMessageReceivers. It's bit of difficult task to review raw source files instead  can you please provide your modification as a svn patch file for Axis2 trunk.  It Would be great if you can provide a unit test for this too . 

[1] - http://code.google.com/p/google-gson/
                  
> 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
>         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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "Paul Hodchenkov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13268586#comment-13268586 ] 

Paul Hodchenkov commented on AXIS2-5158:
----------------------------------------

P.S in http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/json/src/org/apache/axis2/json/AbstractJSONMessageFormatter.java?view=markup on line 176 there is a statement:
"Mapped format cannot handle element with namespaces.. So cannot handle Faults". 
Actually, it may serialize the fault : just need to call setIgnoreNamespaces in mapped jettison message formatter, so client will receive a proper json response for fault instead of plain text string.
                
> 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


[jira] [Commented] (AXIS2-5158) Improve JSON support in Axis2

Posted by "PNS (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/AXIS2-5158?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13151546#comment-13151546 ] 

PNS commented on AXIS2-5158:
----------------------------

Axis2 is too mainstream a technology to not support plain vanilla JSON ("Mapped JSON", if you prefer) and to require workarounds. It is really surprising that we have reached version 1.6.1 without a permanent, transparent and working solution.

The sooner this issue is dealt with, the better.
                
> 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
>         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