/** * For internal use only. */ public StAXSOAPModelBuilder(OMMetaFactory metaFactory, XMLStreamReader parser, Detachable detachable, Closeable closeable) { super(metaFactory.getOMFactory(), parser, detachable, closeable); this.metaFactory = metaFactory; }
@Override public SOAPFactory getSOAPFactory(OMMetaFactory metaFactory) { return metaFactory.getSOAP11Factory(); }
@Override public SOAPFactory getSOAPFactory(OMMetaFactory metaFactory) { return metaFactory.getSOAP12Factory(); }
/** * Create an object model builder that reads a plain XML document from the provided * {@link Source}. When used with a {@link DOMSource} or {@link SAXSource}, entities are * expanded, i.e. the method has the same behavior as {@link #createOMBuilder(Node, boolean)} * and {@link #createOMBuilder(SAXSource, boolean)} with {@code expandEntityReferences} set to * {@code true}. * * @param source * the source of the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(Source source) { OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(); return metaFactory.createOMBuilder(metaFactory.getOMFactory(), source); }
return metaFactory.createStAXOMBuilder(metaFactory.getOMFactory(), parser);
/** * Create a new <code>SOAPEnvelope</code> of the same version as the * SOAPEnvelope in the given <code>MessageContext</code> * * @param nsUri * @return SOAPEnvelope */ public static SOAPEnvelope createSOAPEnvelope(String nsUri) { OMMetaFactory domFac = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM); if (nsUri != null && SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(nsUri)) { return domFac.getSOAP11Factory().getDefaultEnvelope(); } else { return domFac.getSOAP12Factory().getDefaultEnvelope(); } }
soapFactory = metaFactory.getSOAP11Factory(); } else if (type.equals(SOAPVersion.SOAP12.getMediaType())) { soapFactory = metaFactory.getSOAP12Factory(); } else { throw new OMException("Unable to determine SOAP version"); return metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP, soapFactory, rootPart, new AttachmentsMimePartProvider(attachments));
/** * Create an object model builder that reads an XML document from the provided character stream * using a specified object model factory and with a given parser configuration. * * @param omFactory * the object model factory to use * @param configuration * the parser configuration to use * @param in * the character stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, StAXParserConfiguration configuration, Reader in) { return omFactory.getMetaFactory().createOMBuilder(omFactory, configuration, new InputSource(in)); }
/** * Create an object model builder for SOAP that reads a message from the provided {@link Source} * using a particular Axiom implementation. The method will select the appropriate * {@link SOAPFactory} based on the namespace URI of the SOAP envelope. * * @param metaFactory * the meta factory for the Axiom implementation to use * @param source * the source of the SOAP message * @return the builder */ public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory, Source source) { return metaFactory.createSOAPModelBuilder(source); }
/** * Create a DOM Document using the org.apache.axiom.soap.SOAPEnvelope * * @param env An org.apache.axiom.soap.SOAPEnvelope instance * @return the DOM Document of the given SOAP Envelope */ 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(); envelope.build(); Element envElem = (Element)envelope; return envElem.getOwnerDocument(); }
/** * Create an object model builder that reads a plain XML document from the provided character * stream with a given parser configuration. * * @param configuration * the parser configuration to use * @param in * the character stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration, Reader in) { OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(); return metaFactory.createOMBuilder(metaFactory.getOMFactory(), configuration, new InputSource(in)); }
/** * Create an object model builder that reads an XML document from the provided {@link Source} * using a specified object model factory. When used with a {@link DOMSource} or * {@link SAXSource}, entities are expanded, i.e. the method has the same behavior as * {@link #createOMBuilder(OMFactory, Node, boolean)} and * {@link #createOMBuilder(OMFactory, SAXSource, boolean)} with {@code expandEntityReferences} * set to {@code true}. * * @param omFactory * the object model factory to use * @param source * the source of the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, Source source) { return omFactory.getMetaFactory().createOMBuilder(omFactory, source); }
/** * Create an object model builder for SOAP that reads a message from the provided character * stream using a particular Axiom implementation. The method will select the appropriate * {@link SOAPFactory} based on the namespace URI of the SOAP envelope. It will configure the * underlying parser as specified by {@link StAXParserConfiguration#SOAP}. * * @param metaFactory * the meta factory for the Axiom implementation to use * @param in * the character stream containing the SOAP message * @return the builder */ public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory, Reader in) { return metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP, new InputSource(in)); }
OMMetaFactory omMetaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM); OMFactory omFac = omMetaFactory.getOMFactory(); OMXMLParserWrapper wrapper = OMXMLBuilderFactory.createOMBuilder(omFac, new FileInputStream("resources/test.xml")) ; Document doc = (Document) wrapper.getDocument();
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 " + } else { soapEnvelope = metaFactory.getSOAP11Factory().getDefaultEnvelope();
/** * Create an object model builder that reads a plain XML document from the provided DOM tree. * * @param node * the DOM node; must be a {@link Node#DOCUMENT_NODE} or {@link Node#ELEMENT_NODE} * @param expandEntityReferences * Determines how {@link EntityReference} nodes are handled: * <ul> * <li>If the parameter is <code>false</code> then a single {@link OMEntityReference} * will be created for each {@link EntityReference}. The child nodes of * {@link EntityReference} nodes are not taken into account. * <li>If the parameter is <code>true</code> then no {@link OMEntityReference} nodes * are created and the children of {@link EntityReference} nodes are converted and * inserted into the Axiom tree. * </ul> * @return the builder */ public static OMXMLParserWrapper createOMBuilder(Node node, boolean expandEntityReferences) { OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(); return metaFactory.createOMBuilder(metaFactory.getOMFactory(), node, expandEntityReferences); }
@Override public SOAPFactory getSOAPFactory(OMMetaFactory metaFactory) { return metaFactory.getSOAP11Factory(); }
@Override public SOAPFactory getSOAPFactory(OMMetaFactory metaFactory) { return metaFactory.getSOAP12Factory(); }
/** * Create an object model builder that reads an XML document from the provided input stream * using a specified object model factory and with a given parser configuration. * * @param omFactory * the object model factory to use * @param configuration * the parser configuration to use * @param in * the input stream representing the XML document * @param encoding * the charset encoding of the XML document or <code>null</code> if the parser should * determine the charset encoding * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, StAXParserConfiguration configuration, InputStream in, String encoding) { InputSource is = new InputSource(in); is.setEncoding(encoding); return omFactory.getMetaFactory().createOMBuilder(omFactory, configuration, is); }
/** * Create an object model builder for SOAP that reads a message from the provided input stream, * using a particular Axiom implementation and a given charset encoding. The method will select * the appropriate {@link SOAPFactory} based on the namespace URI of the SOAP envelope. It will * configure the underlying parser as specified by {@link StAXParserConfiguration#SOAP}. * * @param metaFactory * the meta factory for the Axiom implementation to use * @param in * the input stream containing the SOAP message * @param encoding * the charset encoding of the SOAP message or <code>null</code> if the parser should * determine the charset encoding * @return the builder */ public static SOAPModelBuilder createSOAPModelBuilder(OMMetaFactory metaFactory, InputStream in, String encoding) { InputSource is = new InputSource(in); is.setEncoding(encoding); return metaFactory.createSOAPModelBuilder(StAXParserConfiguration.SOAP, is); }