[ 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-unsubscr...@axis.apache.org For additional commands, e-mail: java-dev-h...@axis.apache.org