Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.1
    • Fix Version/s: None
    • Component/s: json
    • Labels:
      None

      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/

      1. JSONMessageFormatter.java
        4 kB
        Paul Khodchenkov
      2. JSONMappedBuilder.java
        0.6 kB
        Paul Khodchenkov
      3. JSONBadgerfishMessageFormatter.java
        4 kB
        Paul Khodchenkov
      4. JSONBadgerfishBuilder.java
        0.5 kB
        Paul Khodchenkov
      5. ExtendedMappedXMLStreamWriter.java
        2 kB
        Paul Khodchenkov
      6. AbstractJSONMessageFormatter.java
        3 kB
        Paul Khodchenkov
      7. AbstractJSONBuilder.java
        5 kB
        Paul Khodchenkov

        Issue Links

          Activity

          Paul Khodchenkov created issue -
          Paul Khodchenkov made changes -
          Field Original Value New Value
          Attachment AbstractJSONBuilder.java [ 12497430 ]
          Attachment AbstractJSONMessageFormatter.java [ 12497431 ]
          Attachment ExtendedMappedXMLStreamWriter.java [ 12497432 ]
          Attachment JSONBadgerfishBuilder.java [ 12497433 ]
          Attachment JSONBadgerfishMessageFormatter.java [ 12497434 ]
          Attachment JSONMappedBuilder.java [ 12497435 ]
          Attachment JSONMessageFormatter.java [ 12497436 ]
          Paul Khodchenkov made changes -
          Description 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/
          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/
          Paul Khodchenkov made changes -
          Component/s json [ 12314363 ]
          Component/s databinding [ 12310112 ]
          Andreas Veithen made changes -
          Link This issue is blocked by AXIOM-399 [ AXIOM-399 ]
          Andreas Veithen made changes -
          Assignee Andreas Veithen [ veithen ]

            People

            • Assignee:
              Andreas Veithen
              Reporter:
              Paul Khodchenkov
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Development