/** * 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(); }
/** * 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(); }
/** * 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(); }
public static org.apache.axiom.soap.SOAPEnvelope getSOAPEnvelopeFromDOOMDocument(org.w3c.dom.Document doc) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder(((OMElement)doc.getDocumentElement()).getXMLStreamReader()).getSOAPEnvelope(); }
public static org.apache.axiom.soap.SOAPEnvelope toOMSOAPEnvelope(org.w3c.dom.Element elem) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder(((OMElement)elem).getXMLStreamReader()).getSOAPEnvelope(); }
private SOAPEnvelope getSOAPEnvFromOM(OMElement inlineElement) { return OMXMLBuilderFactory.createStAXSOAPModelBuilder( inlineElement.getXMLStreamReader()).getSOAPEnvelope(); }
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(new StringReader(payload)).getSOAPEnvelope();
protected void assertSOAPEchoResponse(String textValue, XMLStreamReader reader) { SOAPEnvelope env = OMXMLBuilderFactory.createStAXSOAPModelBuilder(reader).getSOAPEnvelope(); assertEchoResponse(textValue, env.getBody().getFirstElement()); }
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 a DOM Document using the org.apache.axiom.soap.SOAPEnvelope * * @param env An org.apache.axiom.soap.SOAPEnvelope instance * @return the org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl of the given SOAP Envelope */ public static Element toDOOMSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) { return (Element)OMXMLBuilderFactory.createStAXSOAPModelBuilder( OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM), env.getXMLStreamReader()).getSOAPEnvelope(); }
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 void setContent(Source source) throws SOAPException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLStreamReader reader; if (source instanceof StreamSource) { reader = inputFactory.createXMLStreamReader(source); } else { Result result = new StreamResult(baos); Transformer xformer = TransformerFactory.newInstance().newTransformer(); xformer.transform(source, result); InputStream is = new ByteArrayInputStream(baos.toByteArray()); reader = inputFactory.createXMLStreamReader(is); } SOAPModelBuilder builder1 = OMXMLBuilderFactory.createStAXSOAPModelBuilder( envelope.omTarget.getOMFactory().getMetaFactory(), reader); envelope = new SOAPEnvelopeImpl(builder1.getSOAPEnvelope()); envelope.omTarget.build(); this.document = envelope.getOwnerDocument(); envelope.setSOAPPartParent(this); } catch (TransformerFactoryConfigurationError e) { log.error(e); throw new SOAPException(e); } catch (Exception e) { log.error(e); throw new SOAPException(e); } }
final InputStream in = isFault ? conn.getErrorStream() : conn.getInputStream(); try { final SOAPEnvelope responseEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(in, "UTF-8").getSOAPEnvelope(); // TODO: encoding! return new SOAPResponse() { @Override
/** * Converts a {@link Document} representation of the SOAP Envelope into a Axiom representation. * * @param document The standard DOM representation of the SOAP Envelope * @return An {@link SOAPEnvelope} object containing the Axiom representation of the SOAP envelope, or <br> * <code>null</code> if the conversion fails */ public static SOAPEnvelope convertDOMSOAPEnvToAxiom(final Document document) { try { // If no security action is performed the Santuario may not have been initialized which causes the // XMLUtils.outputDOM to fail if (!org.apache.xml.security.Init.isInitialized()) org.apache.xml.security.Init.init(); // The call of the Document.normalizeDocument() method is to fix the exception described here: // http://apache-xml-project.6118.n7.nabble.com/Undeclared-namespace-prefix-quot-ds-quot-error-td36346.html document.normalizeDocument(); final ByteArrayOutputStream os = new ByteArrayOutputStream(); XMLUtils.outputDOM(document.getDocumentElement(), os, true); final ByteArrayInputStream bais = new ByteArrayInputStream(os.toByteArray()); final SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createSOAPModelBuilder(bais, null); final SOAPEnvelope env = stAXSOAPModelBuilder.getSOAPEnvelope(); env.build(); return env; } catch (final Exception e) { // If anything goes wrong converting the document, just return null return null; } }
new StAXSource(docElem.getXMLStreamReader()), attachmentAccessor).getSOAPEnvelope();
public XMLMessage decode(ContentType contentType, byte[] message) throws Exception { XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType); if (type == null) { throw new Exception("Unrecognized content type " + contentType); } ByteArrayInputStream in = new ByteArrayInputStream(message); if (type == XMLMessage.Type.SWA) { Attachments attachments = new Attachments(in, contentType.toString()); OMElement payload = OMXMLBuilderFactory.createSOAPModelBuilder( attachments.getSOAPPartInputStream(), null).getSOAPEnvelope().getBody().getFirstElement(); return new XMLMessage(payload, type, attachments); } else { String charset = contentType.getParameter("charset"); OMElement payload; if (type == XMLMessage.Type.POX) { payload = OMXMLBuilderFactory.createOMBuilder(in, charset).getDocumentElement(); } else { payload = OMXMLBuilderFactory.createSOAPModelBuilder(in, charset).getSOAPEnvelope().getBody().getFirstElement(); } return new XMLMessage(payload, type); } } };
public XMLMessage decode(ContentType contentType, byte[] message) throws Exception { XMLMessage.Type type = XMLMessage.getTypeFromContentType(contentType); if (type == null) { throw new Exception("Unrecognized content type " + contentType); } ByteArrayInputStream in = new ByteArrayInputStream(message); if (type == XMLMessage.Type.SWA) { Attachments attachments = new Attachments(in, contentType.toString()); OMElement payload = OMXMLBuilderFactory.createSOAPModelBuilder( attachments.getSOAPPartInputStream(), null).getSOAPEnvelope().getBody().getFirstElement(); return new XMLMessage(payload, type, attachments); } else { String charset = contentType.getParameter("charset"); OMElement payload; if (type == XMLMessage.Type.POX) { payload = OMXMLBuilderFactory.createOMBuilder(in, charset).getDocumentElement(); } else { payload = OMXMLBuilderFactory.createSOAPModelBuilder(in, charset).getSOAPEnvelope().getBody().getFirstElement(); } return new XMLMessage(payload, type); } } };
SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder( reader); SOAPEnvelope envelope = stAXSOAPModelBuilder.getSOAPEnvelope(); return stAXSOAPModelBuilder.getSOAPEnvelope(); } catch (Exception e) { throw new WSSecurityException(e.getMessage());
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(); } } }
SOAPEnvelope envelope = OMXMLBuilderFactory.createSOAPModelBuilder(streamReader).getSOAPEnvelope();