/** * Create an object model builder that reads a plain XML document from the provided input stream * with a given parser configuration. * * @param configuration * the parser configuration to use * @param in * the input stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(StAXParserConfiguration configuration, InputStream in) { return createOMBuilder(configuration, in, null); }
public XMLMessage decode(ContentType contentType, String message) throws Exception { XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType); if (type == null) { throw new Exception("Unrecognized content type " + contentType); } OMElement payload; if (type == XMLMessage.Type.POX) { payload = OMXMLBuilderFactory.createOMBuilder(new StringReader(message)).getDocumentElement(); } else { payload = OMXMLBuilderFactory.createSOAPModelBuilder(new StringReader(message)).getSOAPEnvelope().getBody().getFirstElement(); } return new XMLMessage(payload, type); } };
public OMElement convert(XMLStreamReader s) { return OMXMLBuilderFactory .createStAXOMBuilder(OMAbstractFactory.getOMFactory(), s) .getDocumentElement(); }
/** * Converts a given {@link Document} to an AXIOM {@link org.apache.axiom.soap.SOAPEnvelope}. * * @param document the document to be converted * @return the converted envelope * @throws IllegalArgumentException in case of errors */ public static SOAPEnvelope toEnvelope(Document document) { return OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(document)).getSOAPEnvelope(); }
SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder( reader); SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope(); ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray()); SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(bais, null); return stAXSOAPModelBuilder.getSOAPEnvelope(); } catch (Exception e) {
public OMElement getNode(Charset charset) { try { out.close(); } catch (IOException e) { handleException("Error while closing output stream", e); } if (expectedOutput == ResultBuilderFactory.Output.TEXT) { return TextFileDataSource.createOMSourcedElement(tmp, charset); } else { XMLStreamReader reader; try { reader = StAXUtils.createXMLStreamReader(tmp.getInputStream()); } catch (XMLStreamException e) { handleException("Unable to parse the XML output", e); return null; } catch (IOException e) { handleException("I/O error while reading temporary file", e); return null; } if (expectedOutput == ResultBuilderFactory.Output.SOAP_ENVELOPE) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader).getSOAPEnvelope(); } else { return OMXMLBuilderFactory.createStAXOMBuilder(reader).getDocumentElement(); } } }
public static org.apache.axiom.soap.SOAPEnvelope getSOAPEnvelopeFromDOOMDocument(org.w3c.dom.Document doc) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder(((OMElement)doc.getDocumentElement()).getXMLStreamReader()).getSOAPEnvelope(); }
/** * Converts a given {@link Document} to an AXIOM {@link org.apache.axiom.soap.SOAPEnvelope}. * * @param document the document to be converted * @return the converted envelope * @throws IllegalArgumentException in case of errors */ public static SOAPEnvelope toEnvelope(Document document) { return OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(document)).getSOAPEnvelope(); }
private SOAPEnvelope getSOAPEnvFromOM(OMElement inlineElement) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder( inlineElement.getXMLStreamReader()).getSOAPEnvelope(); }
/** * Create an object model builder that reads a plain XML document from the provided input stream * with the default parser configuration defined by {@link StAXParserConfiguration#DEFAULT}. * * @param in * the input stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(InputStream in) { return createOMBuilder(StAXParserConfiguration.DEFAULT, in); }
public XMLMessage decode(ContentType contentType, String message) throws Exception { XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType); if (type == null) { throw new Exception("Unrecognized content type " + contentType); } OMElement payload; if (type == XMLMessage.Type.POX) { payload = OMXMLBuilderFactory.createOMBuilder(new StringReader(message)).getDocumentElement(); } else { payload = OMXMLBuilderFactory.createSOAPModelBuilder(new StringReader(message)).getSOAPEnvelope().getBody().getFirstElement(); } return new XMLMessage(payload, type); } };
/** * Create an object model builder for SOAP that reads a message from the provided {@link Source}. * The method will select the appropriate {@link SOAPFactory} based on the namespace URI of * the SOAP envelope. * * @param source * the source of the SOAP message * @return the builder */ public static SOAPModelBuilder createSOAPModelBuilder(Source source) { return createSOAPModelBuilder(OMAbstractFactory.getMetaFactory(), source); }
public static OMElement getOMElement(SOAPEnvelope response) { return OMXMLBuilderFactory.createStAXOMBuilder(response.getXMLStreamReader()).getDocumentElement(); }
public static org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(org.w3c.dom.Element elem) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder(((OMElement)elem).getXMLStreamReader()).getSOAPEnvelope(); }
/** * Create an object model builder that reads a plain XML document from the provided character * stream with the default parser configuration defined by * {@link StAXParserConfiguration#DEFAULT}. * * @param in * the character stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(Reader in) { return createOMBuilder(StAXParserConfiguration.DEFAULT, in); }
if (attachments.getAttachmentSpecType().equals( MTOMConstants.MTOM_TYPE)) { return OMXMLBuilderFactory.createSOAPModelBuilder(attachments); } else { return OMXMLBuilderFactory.createSOAPModelBuilder(attachments.getRootPartInputStream(), charSetEncoding); return OMXMLBuilderFactory.createOMBuilder(StAXParserConfiguration.DEFAULT, attachments); } else { return OMXMLBuilderFactory.createOMBuilder(attachments.getRootPartInputStream(), charSetEncoding);
/** * Converts a given {@link Document} to an AXIOM {@link org.apache.axiom.soap.SOAPEnvelope}. * * @param document the document to be converted * @return the converted envelope * @throws IllegalArgumentException in case of errors */ public static SOAPEnvelope toEnvelope(Document document) { return OMXMLBuilderFactory.createSOAPModelBuilder(new DOMSource(document)).getSOAPEnvelope(); }
private OMElement convertStringToOMElement(String stringElement) throws IOException { if (null == stringElement || stringElement.trim().equals("")) { return null; } try { Reader in = new StringReader(stringElement); XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in); OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(parser); OMElement documentElement = builder.getDocumentElement(); XMLStreamReader llomReader = documentElement.getXMLStreamReader(); OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM); OMFactory doomFactory = metaFactory.getOMFactory(); OMXMLParserWrapper doomBuilder = OMXMLBuilderFactory.createStAXOMBuilder(doomFactory, llomReader); return doomBuilder.getDocumentElement(); } catch (XMLStreamException e) { log.error("Cannot convert de-serialized string to OMElement. Could not create XML stream.", e); // IOException only has a constructor supporting exception chaining starting with Java 1.6 IOException ex = new IOException("Cannot convert de-serialized string to OMElement. Could not create XML stream."); ex.initCause(e); throw ex; } } }
protected void assertSOAPEchoResponse(String textValue, XMLStreamReader reader) { SOAPEnvelope env = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader).getSOAPEnvelope(); assertEchoResponse(textValue, env.getBody().getFirstElement()); }
/** * Create an object model builder that reads an XML document from the provided input stream * using a specified object model factory and with the default parser configuration defined by * {@link StAXParserConfiguration#DEFAULT}. * * @param omFactory * the object model factory to use * @param in * the input stream representing the XML document * @return the builder */ public static OMXMLParserWrapper createOMBuilder(OMFactory omFactory, InputStream in) { return createOMBuilder(omFactory, StAXParserConfiguration.DEFAULT, in); }