Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement.serializeAndConsume()


        XMLFault fault = new XMLFault(XMLFaultCode.SENDER, reason);
        msg.setXMLFault(fault);
       
        OMElement om = msg.getAsOMElement();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        om.serializeAndConsume(baos);
       
        String env = new String(baos.toByteArray());
        assertTrue(env.indexOf("faultcode") > 0);
        assertTrue(env.indexOf("faultstring") > 0);
    }
View Full Code Here


    OMElement om = m.getAsOMElement();
           
        // Serialize the Envelope using the same mechanism as the
        // HTTP client.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        om.serializeAndConsume(baos, new OMOutputFormat());
       
    // To check that the output is correct, get the String contents of the
    // reader
        String newText = baos.toString();
        TestLogger.logger.debug(newText);
View Full Code Here

        OMElement om = m.getAsOMElement();
               
        // Serialize the Envelope using the same mechanism as the
        // HTTP client.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        om.serializeAndConsume(baos, new OMOutputFormat());
       
        // To check that the output is correct, get the String contents of the
        // reader
        String newText = baos.toString();
        TestLogger.logger.debug(newText);
View Full Code Here

        OMElement om = m.getAsOMElement();
               
        // Serialize the Envelope using the same mechanism as the
        // HTTP client.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        om.serializeAndConsume(baos, new OMOutputFormat());
       
        // To check that the output is correct, get the String contents of the
        // reader
        String newText = baos.toString();
        TestLogger.logger.debug(newText);
View Full Code Here

            OMElement element = new StAXOMBuilder(inputFile).getDocumentElement();

            // output it using binary xml outputter
            XMLStreamWriter streamWriter = new StAXDocumentSerializer(new FileOutputStream(tempFile));
            streamWriter.writeStartDocument();
            element.serializeAndConsume(streamWriter);
            streamWriter.writeEndDocument();

            // now let's read the binary file in to Axiom
            XMLStreamReader streamReader = new StAXDocumentParser(new FileInputStream(tempFile));
            StAXBuilder builder = new StAXOMBuilder(streamReader);
View Full Code Here

    try {
      //Creates StAX document serializer which actually implements the XMLStreamWriter
      XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
      //Since we drop the SOAP envelop we have to manually write the start document and the end document events
      streamWriter.writeStartDocument();
      element.serializeAndConsume(streamWriter);
      streamWriter.writeEndDocument();
     
      return outStream.toByteArray();
     
    } catch (XMLStreamException xmlse) {
View Full Code Here

      //Since we drop the SOAP envelop we have to manually write the start document and the end document events     
      streamWriter.writeStartDocument();
      if (preserve) {
        element.serialize(streamWriter);
      } else {
        element.serializeAndConsume(streamWriter);
      }
      streamWriter.writeEndDocument();
    } catch (XMLStreamException xmlse) {
      logger.error(xmlse.getMessage());
      throw new AxisFault(xmlse.getMessage(), xmlse);
View Full Code Here

    ByteArrayOutputStream outStream = new ByteArrayOutputStream();
   
    try {
      //Creates StAX document serializer which actually implements the XMLStreamWriter
      XMLStreamWriter streamWriter = new StAXDocumentSerializer(outStream);
      element.serializeAndConsume(streamWriter);
      //TODO Looks like the SOAP envelop doesn't have an end document tag. Find out why?
      streamWriter.writeEndDocument();
     
      return outStream.toByteArray();
     
View Full Code Here

      //Create the StAX document serializer
      XMLStreamWriter streamWriter = new StAXDocumentSerializer(outputStream);
      if (preserve) {
        element.serialize(streamWriter);
      } else {
        element.serializeAndConsume(streamWriter);
      }
//      TODO Looks like the SOAP envelop doesn't have a end document tag. Find out why?
      streamWriter.writeEndDocument();
    } catch (XMLStreamException xmlse) {
      logger.error(xmlse.getMessage());
View Full Code Here

            //otherwise serialize the OM by expanding the tree
        } else {
            try {
                ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
                XMLStreamWriter jsonWriter = getJSONWriter(bytesOut);
                element.serializeAndConsume(jsonWriter);
                jsonWriter.writeEndDocument();

                return bytesOut.toByteArray();

            } catch (XMLStreamException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.