/** * 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); }
/** * 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(); }
/** * Create an object model builder for SOAP that reads a message from the provided character * stream. 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 in * the character stream containing the SOAP message * @return the builder */ public static SOAPModelBuilder createSOAPModelBuilder(Reader in) { return createSOAPModelBuilder(OMAbstractFactory.getMetaFactory(), in); }
/** * 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(); }
/** * Create an object model builder for SOAP that reads a message from the provided input stream, * using 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 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(InputStream in, String encoding) { return createSOAPModelBuilder(OMAbstractFactory.getMetaFactory(), in, encoding); }
/** * Create a SOAP model builder. This method delegates to * {@link OMXMLBuilderFactory#createSOAPModelBuilder(InputStream, String)} but generates * additional logging if an error occurs. * * @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(InputStream in, String encoding) { try { return OMXMLBuilderFactory.createSOAPModelBuilder(in, encoding); } catch (OMException e) { log.info("OMException in getSOAPBuilder", e); try { log.info("Remaining input stream :[" + new String(IOUtils.toByteArray(in), encoding) + "]"); } catch (IOException e1) { // Nothing here? } throw e; } }
/** * Create an MTOM aware model builder from the provided {@link Attachments} object. The method * will determine the SOAP version based on the content type information from the * {@link Attachments} object. It will configure the underlying parser as specified by * {@link StAXParserConfiguration#SOAP}. * * @param attachments * an {@link Attachments} object that must have been created from an input stream * @return the builder * @throws OMException * if an error occurs while processing the content type information from the * {@link Attachments} object */ public static SOAPModelBuilder createSOAPModelBuilder(Attachments attachments) { return createSOAPModelBuilder(OMAbstractFactory.getMetaFactory(), attachments); }
/** * Create a SOAP model builder. This method delegates to * {@link OMXMLBuilderFactory#createSOAPModelBuilder(InputStream, String)} but generates * additional logging if an error occurs. * * @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(InputStream in, String encoding) { try { return OMXMLBuilderFactory.createSOAPModelBuilder(in, encoding); } catch (OMException e) { log.info("OMException in getSOAPBuilder", e); try { log.info("Remaining input stream :[" + new String(IOUtils.toByteArray(in), encoding) + "]"); } catch (IOException e1) { // Nothing here? } throw e; } }
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 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); } };
@Override public void setDocument(Document document) { // save the Soap Action String soapAction = getSoapAction(); // replace the Axiom message setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), new DOMSource(document)).getSOAPMessage()); // restore the Soap Action setSoapAction(soapAction); }
@Override public void setDocument(Document document) { // save the Soap Action String soapAction = getSoapAction(); // replace the Axiom message setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), new DOMSource(document)).getSOAPMessage()); // restore the Soap Action setSoapAction(soapAction); }
@Override public void setDocument(Document document) { // save the Soap Action String soapAction = getSoapAction(); // replace the Axiom message setAxiomMessage(OMXMLBuilderFactory.createSOAPModelBuilder(axiomFactory.getMetaFactory(), new DOMSource(document)).getSOAPMessage()); // restore the Soap Action setSoapAction(soapAction); }
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); } } };
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault { try { String charSetEncoding = (String) messageContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); // createSOAPModelBuilder takes care of configuring the underlying parser to // avoid the security issue described in CVE-2010-1632 OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(inputStream, charSetEncoding); messageContext.setProperty(Constants.BUILDER, builder); SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement(); BuilderUtil .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope); BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument() .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI()); return envelope; } catch (IOException e) { throw AxisFault.makeFault(e); } }
public OMElement processMIMEMessage(Attachments attachments, String contentType, MessageContext messageContext) throws AxisFault { try { // TODO: this will be changed later (see AXIS2-5308) messageContext.setAttachmentMap(attachments); SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments); OMDocument document = builder.getDocument(); String charsetEncoding = document.getCharsetEncoding(); if (charsetEncoding == null) { charsetEncoding = MessageContext.UTF_8; } messageContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charsetEncoding); SOAPEnvelope envelope = (SOAPEnvelope)document.getOMDocumentElement(); // TODO: Axiom should take care of this, but we need to validate that // BuilderUtil // .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope); // BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument() // .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI()); messageContext.setDoingMTOM(true); return envelope; } catch (OMException e) { throw AxisFault.makeFault(e); } } }
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault { try { String charSetEncoding = (String) messageContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); // Apply a detachable inputstream. This can be used later // to (a) get the length of the incoming message or (b) // free transport resources. DetachableInputStream is = new DetachableInputStream(inputStream); messageContext.setProperty(Constants.DETACHABLE_INPUT_STREAM, is); // createSOAPModelBuilder takes care of configuring the underlying parser to // avoid the security issue described in CVE-2010-1632 OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(is, charSetEncoding); SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement(); BuilderUtil .validateSOAPVersion(BuilderUtil.getEnvelopeNamespace(contentType), envelope); BuilderUtil.validateCharSetEncoding(charSetEncoding, builder.getDocument() .getCharsetEncoding(), envelope.getNamespace().getNamespaceURI()); return envelope; } catch (IOException e) { throw AxisFault.makeFault(e); } }
SOAPModelBuilder builder = OMXMLBuilderFactory.createSOAPModelBuilder(attachments); messageContext.setProperty(Constants.BUILDER, builder); OMDocument document = builder.getDocument();