Package org.apache.axiom.om

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


       
        // Likewise, a ByteArrayDataSource does not consume the backing object when
        // written.  Thus serializing the OMSourcedElement should not cause the expansion
        // of the OMSourcedElement.
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        parent.serialize(baos);
        String output = baos.toString(encoding);
//        System.out.println(output);
        assertTrue("The payload was not present in the output",
                   output.indexOf(payload1) > 0);
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
View Full Code Here


        // Serialize and cache.  This should cause expansion and update the name to match the testDocument string
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        try {
            root.serialize(writer);
        } catch (Exception e) {
            // Current Behavior
            // The current OMSourceElementImpl ensures that the namespace and localName
            // are consistent with the original setting.
            return;
View Full Code Here

        assertTrue("Serialized text error" + result, result.indexOf("1930110111") > 0);

        // Serialize again
        writer = new StringWriter();
        xmlwriter = StAXUtils.createXMLStreamWriter(writer);
        root.serialize(writer);
        xmlwriter.flush();
        result = writer.toString();

        assertTrue(element.getLocalName().equals("library"));
        assertTrue(element.getNamespace().getNamespaceURI().equals(
View Full Code Here

            } else {
                    OMElement omElement = messageContext.getEnvelope().getBody().getFirstElement();
                    if (omElement != null) {
                        try {
                            if (preserve) {
                                omElement.serialize(outputStream, format);
                            } else {
                                omElement.serializeAndConsume(outputStream, format);
                            }
                        } catch (XMLStreamException e) {
                            throw AxisFault.makeFault(e);
View Full Code Here

    throws Exception {
        QName qname = new QName(addressingNamespace, "EndpointReference", "wsa");
        OMElement omElement =
            EndpointReferenceHelper.toOM(omFactory, axis2EPR, qname, addressingNamespace);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        omElement.serialize(baos);
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());       
        Source eprInfoset = new StreamSource(bais);
       
        return convertFromSource(eprInfoset);
    }
View Full Code Here

           
            // Get the namespace so that we can determine SOAP11 or SOAP12
            OMNamespace ns = element.getNamespace();
           
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            element.serialize(outStream);
           
            // In some cases (usually inbound) the builder will not be closed after
            // serialization.  In that case it should be closed manually.
            if (element.getBuilder() != null && !element.getBuilder().isCompleted()) {
                element.close(false);
View Full Code Here

        if (this.wsdlFound) {
            AxisService2OM axisService2WOM = new AxisService2OM(this,
                    serviceURL, "document", "literal", servicePath);
            try {
                OMElement wsdlElement = axisService2WOM.generateOM();
                wsdlElement.serialize(out);
                out.flush();
                out.close();
            } catch (Exception e) {
                throw new AxisFault(e);
            }
View Full Code Here

    private void getWSDL2(OutputStream out, String[] serviceURL) throws AxisFault {
        if (this.wsdlFound) {
            AxisService2WSDL2 axisService2WSDL2 = new AxisService2WSDL2(this, serviceURL);
            try {
                OMElement wsdlElement = axisService2WSDL2.generateOM();
                wsdlElement.serialize(out);
                out.flush();
                out.close();
            } catch (Exception e) {
                throw new AxisFault(e);
            }
View Full Code Here

        TransformationContext context = new TransformationContextImpl();
        DataType dt = new DataTypeImpl(Object.class, new XMLType(new QName("http://foo.com", "root"), null));
        context.setTargetDataType(dt);
        OMElement element = t1.transform(new JSONObject(JSON_STR), context);
        StringWriter writer = new StringWriter();
        element.serialize(writer);
        // System.out.println(writer.toString());
    }

    public void testString2JSON() throws Exception {
        String json = "{\"name\":\"John\",\"age\":25}";
View Full Code Here

        } else if (o instanceof OMElement) {
            OMElement omElement = (OMElement) o;
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                omElement.serialize(baos);
                return new ByteArrayInputStream(baos.toByteArray());
            } catch (XMLStreamException e) {
                handleException("Error converting to a StreamSource", 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.