Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMMetaFactory


        validate(getClass().getResourceAsStream("soap-request.xml"), getClass().getResource("schema.xsd"));
    }

    // START SNIPPET: dom
    public void validateUsingDOM(InputStream in, URL schemaUrl) throws Exception {
        OMMetaFactory mf = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(mf, in, "UTF-8");
        SOAPEnvelope envelope = builder.getSOAPEnvelope();
        OMElement bodyContent = envelope.getBody().getFirstElement();
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = schemaFactory.newSchema(schemaUrl);
View Full Code Here


import junit.framework.TestCase;

public class DOMFeatureTest extends TestCase {
    public void test() {
        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        assertTrue(metaFactory instanceof OMDOMMetaFactory);
    }
View Full Code Here

   
    static Implementation createDefaultImplementation(Loader loader, String className) {
        if (log.isDebugEnabled()) {
            log.debug("Creating default implementation for class " + className);
        }
        OMMetaFactory metaFactory = (OMMetaFactory)load(loader, className);
        return metaFactory == null ? null : new Implementation(null, metaFactory,
                new Feature[] { new Feature(OMAbstractFactory.FEATURE_DEFAULT, Integer.MAX_VALUE) });
    }
View Full Code Here

        String loaderClassName = implementation.getAttributeNS(null, "loader");
        if (loaderClassName.length() == 0) {
            log.error("Encountered " + QNAME_IMPLEMENTATION + " element without loader attribute");
            return null;
        }
        OMMetaFactory metaFactory = ((OMMetaFactoryLoader)load(loader, loaderClassName)).load(null);
        if (metaFactory == null) {
            return null;
        }
        List/*<Feature>*/ features = new ArrayList();
        Node child = implementation.getFirstChild();
View Full Code Here

    private static final Log log = LogFactory.getLog(ImplementationFactory.class);
   
    private ImplementationFactory() {}
   
    static Implementation createDefaultImplementation(Loader loader, String className) {
        OMMetaFactory metaFactory = (OMMetaFactory)load(loader, className);
        return metaFactory == null ? null : new Implementation(null, metaFactory,
                new Feature[] { new Feature(OMAbstractFactory.FEATURE_DEFAULT, Integer.MAX_VALUE) });
    }
View Full Code Here

        String loaderClassName = implementation.getAttributeNS(null, "loader");
        if (loaderClassName.length() == 0) {
            log.error("Encountered " + QNAME_IMPLEMENTATION + " element without loader attribute");
            return null;
        }
        OMMetaFactory metaFactory = ((OMMetaFactoryLoader)load(loader, loaderClassName)).load(null);
        if (metaFactory == null) {
            return null;
        }
        List/*<Feature>*/ features = new ArrayList();
        Node child = implementation.getFirstChild();
View Full Code Here

        soapMessage = parentSoapMsg;

        String charset;
        boolean isMTOM;
        String soapEnvelopeNamespaceURI;
        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        SOAPFactory soapFactory;
        if (contentType == null) {
            charset = null;
            isMTOM = false;
            soapFactory = metaFactory.getSOAP11Factory();
            soapEnvelopeNamespaceURI = null;
        } else {
            MediaType baseType = contentType.getMediaType();
            MediaType soapContentType;
            if (baseType.equals(MediaType.APPLICATION_XOP_XML)) {
                isMTOM = true;
                String typeParam = contentType.getParameter("type");
                if (typeParam == null) {
                    throw new SOAPException("Missing 'type' parameter in XOP content type");
                } else {
                    try {
                        soapContentType = new ContentType(typeParam).getMediaType();
                    } catch (ParseException ex) {
                        throw new SOAPException("Failed to parse the 'type' parameter", ex);
                    }
                }
            } else {
                isMTOM = false;
                soapContentType = baseType;
            }
           
            if (soapContentType.equals(MediaType.TEXT_XML)) {
                soapEnvelopeNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                soapFactory = metaFactory.getSOAP11Factory();
            } else if (soapContentType.equals(MediaType.APPLICATION_SOAP_XML)) {
                soapEnvelopeNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                soapFactory = metaFactory.getSOAP12Factory();
            } else {
                throw new SOAPException("Unrecognized content type '" + soapContentType + "'");
            }
           
            charset = contentType.getParameter("charset");
View Full Code Here

    public static Document getDocumentFromSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
        env.build();

        //Check the namespace and find SOAP version and factory
        String nsURI;
        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        SOAPFactory factory;
        if (env.getNamespace().getNamespaceURI()
                .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
            nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
            factory = metaFactory.getSOAP11Factory();
        } else {
            nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
            factory = metaFactory.getSOAP12Factory();
        }

        StAXSOAPModelBuilder stAXSOAPModelBuilder =
                new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
        SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
View Full Code Here

    public static Element toDOOMSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
        env.build();

        //Check the namespace and find SOAP version and factory
        String nsURI;
        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        SOAPFactory factory;
        if (env.getNamespace().getNamespaceURI()
                .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
            nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
            factory = metaFactory.getSOAP11Factory();
        } else {
            nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
            factory = metaFactory.getSOAP11Factory();
        }

        StAXSOAPModelBuilder stAXSOAPModelBuilder =
                new StAXSOAPModelBuilder(env.getXMLStreamReader(), factory, nsURI);
        SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
View Full Code Here

     * @return a new <CODE>SOAPMessage</CODE> object
     * @throws SOAPException if a SOAP error occurs java.lang.UnsupportedOperationException - if the
     *                       protocol of this MessageFactory instance is DYNAMIC_SOAP_PROTOCOL
     */
    public SOAPMessage createMessage() throws SOAPException {
        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
        SOAPEnvelope soapEnvelope;
        if (soapVersion.equals(SOAPConstants.SOAP_1_2_PROTOCOL)) {
            soapEnvelope = metaFactory.getSOAP12Factory().getDefaultEnvelope();
        } else if (soapVersion.equals(SOAPConstants.DYNAMIC_SOAP_PROTOCOL)) {
            throw new UnsupportedOperationException("createMessage() is not supported for " +
                    "DYNAMIC_SOAP_PROTOCOL");
        } else {
            //SOAP 1.1
            soapEnvelope = metaFactory.getSOAP11Factory().getDefaultEnvelope();
        }
        Element domSoapEnvelope = (Element)soapEnvelope;
        domSoapEnvelope.getOwnerDocument().appendChild(domSoapEnvelope);
        SOAPMessageImpl soapMessage = new SOAPMessageImpl(new SOAPEnvelopeImpl(soapEnvelope));
        soapMessage.setSaveRequired();
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMMetaFactory

Copyright © 2018 www.massapicom. 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.