public final XMLStreamReader getReader() throws XMLStreamException { // Note: we don't actually expect this code to be called because OMSourcedElement should handle // AbstractPushOMDataSource instances differently. Nevertheless the code is functionally correct // (but not very good from a performance point of view, especially for XOP). ByteArrayOutputStream bos = new ByteArrayOutputStream(); serialize(bos, new OMOutputFormat()); return StAXUtils.createXMLStreamReader(new ByteArrayInputStream(bos.toByteArray())); } }
public MTOMXMLStreamWriter(XMLStreamWriter xmlWriter) { this.xmlWriter = xmlWriter; if (log.isTraceEnabled()) { log.trace("Call Stack =" + CommonUtils.callStackToString()); } format = new OMOutputFormat(); optimizationPolicy = new OptimizationPolicyImpl(format); preserveAttachments = true; }
public final byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat format = new OMOutputFormat(); format.setCharSetEncoding(encoding); try { serialize(baos, format); } catch (XMLStreamException ex) { throw new OMException(ex); } return baos.toByteArray(); }
public byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException { // Return the byte array directly if it is the same encoding // Otherwise convert the bytes to the proper encoding ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat format = new OMOutputFormat(); format.setCharSetEncoding(encoding); try { serialize(baos, format); } catch (XMLStreamException e) { throw new OMException(e); } return baos.toByteArray(); }
public String encode(ClientOptions options, XMLMessage message) throws Exception { if (message.getType() == XMLMessage.Type.SWA) { throw new UnsupportedOperationException(); } OMOutputFormat format = new OMOutputFormat(); format.setIgnoreXMLDeclaration(true); StringWriter sw = new StringWriter(); message.getMessageElement().serializeAndConsume(sw, format); return sw.toString(); } };
public String encode(ClientOptions options, XMLMessage message) throws Exception { if (message.getType() == XMLMessage.Type.SWA) { throw new UnsupportedOperationException(); } OMOutputFormat format = new OMOutputFormat(); format.setIgnoreXMLDeclaration(true); StringWriter sw = new StringWriter(); message.getMessageElement().serializeAndConsume(sw, format); return sw.toString(); } };
public String encode(ClientOptions options, XMLMessage message) throws Exception { if (message.getType() == XMLMessage.Type.SWA) { throw new UnsupportedOperationException(); } OMOutputFormat format = new OMOutputFormat(); format.setIgnoreXMLDeclaration(true); StringWriter sw = new StringWriter(); message.getMessageElement().serializeAndConsume(sw, format); return sw.toString(); } };
private void parse() throws SAXException { try { root.internalSerialize(new SAXSerializer(root, contentHandler, lexicalHandler), new OMOutputFormat(), cache); } catch (OutputException ex) { throw (SAXException)ex.getCause(); } } }
private void parse() throws SAXException { try { root.internalSerialize(new SAXSerializer(root, contentHandler, lexicalHandler), new OMOutputFormat(), cache); } catch (OutputException ex) { throw (SAXException)ex.getCause(); } } }
/** * Writes the om to a log.debug. * This method assumes optimized mtom attachments * Also calculates the length of the message. * @param om OMElement * @param log Log * @param limit limit of message to write * @return length of entire message */ public static long logDebug(OMElement om, Log log, int limit) { OMOutputFormat format = new OMOutputFormat(); format.setDoOptimize(true); format.setIgnoreXMLDeclaration(true); return logDebug(om, log, limit, format); }
public byte[] writeBytes() throws AxisFault { try { ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); if (!format.isOptimized()) { OMOutputFormat format2 = new OMOutputFormat(); format2.setCharSetEncoding(charSetEnc); element.serializeAndConsume(bytesOut, format2); return bytesOut.toByteArray(); } else { format.setCharSetEncoding(charSetEnc); format.setDoOptimize(true); element.serializeAndConsume(bytesOut, format); return bytesOut.toByteArray(); } } catch (XMLStreamException e) { throw AxisFault.makeFault(e); } catch (FactoryConfigurationError e) { throw AxisFault.makeFault(e); } }
private OMOutputFormat getOutputFormat() { if (outputFormat != null) { return outputFormat; } else { String charsetEncoding = axiomMessage.getCharsetEncoding(); OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setCharSetEncoding(charsetEncoding); outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11); if (isXopPackage()) { outputFormat.setDoOptimize(true); } else if (!attachments.getContentIDSet().isEmpty()) { outputFormat.setDoingSWA(true); } return outputFormat; } }
private OMOutputFormat getOutputFormat() { if (outputFormat != null) { return outputFormat; } else { String charsetEncoding = axiomMessage.getCharsetEncoding(); OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setCharSetEncoding(charsetEncoding); outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11); if (isXopPackage()) { outputFormat.setDoOptimize(true); } else if (!attachments.getContentIDSet().isEmpty()) { outputFormat.setDoingSWA(true); } return outputFormat; } }
private OMOutputFormat getOutputFormat() { if (outputFormat != null) { return outputFormat; } else { String charsetEncoding = axiomMessage.getCharsetEncoding(); OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setCharSetEncoding(charsetEncoding); outputFormat.setSOAP11(getVersion() == SoapVersion.SOAP_11); if (isXopPackage()) { outputFormat.setDoOptimize(true); } else if (!attachments.getContentIDSet().isEmpty()) { outputFormat.setDoingSWA(true); } return outputFormat; } }
public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception { if (contentType.getBaseType().equals(XMLMessage.Type.SWA.getContentType().getBaseType())) { OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setMimeBoundary(options.getMimeBoundary()); outputFormat.setRootContentId(options.getRootContentId()); return new ContentType(outputFormat.getContentTypeForSwA(SOAP12Constants.SOAP_12_CONTENT_TYPE)); } else { return ContentTypeUtil.addCharset(contentType, options.getCharset()); } }
public byte[] encode(ClientOptions options, XMLMessage message) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setCharSetEncoding(options.getCharset()); outputFormat.setIgnoreXMLDeclaration(true); if (message.getType() == XMLMessage.Type.SWA) { outputFormat.setMimeBoundary(options.getMimeBoundary()); outputFormat.setRootContentId(options.getRootContentId()); StringWriter writer = new StringWriter(); message.getMessageElement().serializeAndConsume(writer); MIMEOutputUtils.writeSOAPWithAttachmentsMessage(writer, baos, message.getAttachments(), outputFormat); } else { message.getMessageElement().serializeAndConsume(baos, outputFormat); } return baos.toByteArray(); } };
public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception { if (contentType.getBaseType().equals(XMLMessage.Type.SWA.getContentType().getBaseType())) { OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setMimeBoundary(options.getMimeBoundary()); outputFormat.setRootContentId(options.getRootContentId()); return new ContentType(outputFormat.getContentTypeForSwA(SOAP12Constants.SOAP_12_CONTENT_TYPE)); } else { return ContentTypeUtil.addCharset(contentType, options.getCharset()); } }
public void writeTo(java.io.Writer writer) throws IOException { Writer out = getFactory().getAbdera().getWriter(); if (!(out instanceof FOMWriter)) { out.writeTo(this, writer); } else { try { OMOutputFormat outputFormat = new OMOutputFormat(); if (getDocument() != null && getDocument().getCharset() != null) outputFormat.setCharSetEncoding(getDocument().getCharset()); serialize(writer, outputFormat); } catch (XMLStreamException e) { throw new FOMException(e); } } }
public ContentType getContentType(ClientOptions options, ContentType contentType) throws Exception { if (contentType.getMediaType().equals(XMLMessage.Type.SWA.getContentType())) { OMOutputFormat outputFormat = new OMOutputFormat(); outputFormat.setMimeBoundary(options.getMimeBoundary()); outputFormat.setRootContentId(options.getRootContentId()); return new ContentType(outputFormat.getContentTypeForSwA(SOAP12Constants.SOAP_12_CONTENT_TYPE)); } else { return contentType.toBuilder().setParameter("charset", options.getCharset()).build(); } }
public void writeTo(java.io.Writer writer) throws IOException { Writer out = getFactory().getAbdera().getWriter(); if (!(out instanceof FOMWriter)) { out.writeTo(this, writer); } else { try { OMOutputFormat outputFormat = new OMOutputFormat(); if (this.getCharsetEncoding() != null) outputFormat.setCharSetEncoding(this.getCharsetEncoding()); MTOMXMLStreamWriter omwriter = new MTOMXMLStreamWriter(StAXUtils.createXMLStreamWriter(writer)); omwriter.setOutputFormat(outputFormat); this.internalSerialize(omwriter); omwriter.flush(); } catch (XMLStreamException e) { throw new FOMException(e); } } }