[
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: [email protected]
For additional commands, e-mail: [email protected]