public void setCharSetEncoding(String charSetEncoding) { format.setCharSetEncoding(charSetEncoding); }
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(); }
ByteArrayOutputStream baos = new ByteArrayOutputStream(); OMOutputFormat format = new OMOutputFormat(); format.setCharSetEncoding(encoding); try { BufferUtils.inputStream2OutputStream(is, baos);
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); } }
public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException { if (log.isDebugEnabled()) { log.debug("serialize xmlWriter="+xmlWriter); } // Some XMLStreamWriters (e.g. MTOMXMLStreamWriter) // provide direct access to the OutputStream. // This allows faster writing. OutputStream os = getOutputStream(xmlWriter); if (os != null) { if (log.isDebugEnabled()) { log.debug("serialize OutputStream optimisation: true"); } String encoding = getCharacterEncoding(xmlWriter); OMOutputFormat format = new OMOutputFormat(); format.setCharSetEncoding(encoding); serialize(os, format); } else { if (log.isDebugEnabled()) { log.debug("serialize OutputStream optimisation: false"); } // Read the bytes into a reader and // write to the writer. XMLStreamReader xmlReader = getReader(); reader2writer(xmlReader, xmlWriter); } } /**
public static void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault { SOAPEnvelope envelope = msgContext.getEnvelope(); OMElement outputMessage = envelope; if ((envelope != null) && msgContext.isDoingREST()) { outputMessage = envelope.getBody().getFirstElement(); } if (outputMessage != null) { try { OMOutputFormat format = new OMOutputFormat(); // Pick the char set encoding from the msgContext String charSetEnc = (String) msgContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); format.setDoOptimize(false); format.setDoingSWA(false); format.setCharSetEncoding(charSetEnc); outputMessage.serializeAndConsume(out, format); out.flush(); } catch (Exception e) { throw AxisFault.makeFault(e); } } else { throw new AxisFault(Messages.getMessage("outMessageNull")); } }
public static void writeMessage(MessageContext msgContext, OutputStream out) throws AxisFault { SOAPEnvelope envelope = msgContext.getEnvelope(); OMElement outputMessage = envelope; if ((envelope != null) && msgContext.isDoingREST()) { outputMessage = envelope.getBody().getFirstElement(); } if (outputMessage != null) { try { OMOutputFormat format = new OMOutputFormat(); // Pick the char set encoding from the msgContext String charSetEnc = (String) msgContext .getProperty(Constants.Configuration.CHARACTER_SET_ENCODING); format.setDoOptimize(false); format.setDoingSWA(false); format.setCharSetEncoding(charSetEnc); outputMessage.serializeAndConsume(out, format); out.flush(); } catch (Exception e) { throw AxisFault.makeFault(e); } } else { throw new AxisFault(Messages.getMessage("outMessageNull")); } }
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; } }
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 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 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()); OMMultipartWriter mpw = new OMMultipartWriter(baos, outputFormat); OutputStream out = mpw.writeRootPart(); message.getMessageElement().serializeAndConsume(out); out.close(); Attachments attachments = message.getAttachments(); for (String id : attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); } else { message.getMessageElement().serializeAndConsume(baos, outputFormat); } return baos.toByteArray(); } };
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()); OMMultipartWriter mpw = new OMMultipartWriter(baos, outputFormat); OutputStream out = mpw.writeRootPart(); message.getMessageElement().serializeAndConsume(out); out.close(); Attachments attachments = message.getAttachments(); for (String id : attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); } else { message.getMessageElement().serializeAndConsume(baos, outputFormat); } return baos.toByteArray(); } };
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 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); } } }
/** * Get the OMOutput format for the given message * @param msgContext the axis message context * @return the OMOutput format to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
/** * Retirn the OMOutputFormat to be used for the message context passed in * @param msgContext the message context * @return the OMOutputFormat to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }
/** * Get the OMOutput format for the given message * @param msgContext the axis message context * @return the OMOutput format to be used */ public static OMOutputFormat getOMOutputFormat(MessageContext msgContext) { OMOutputFormat format = new OMOutputFormat(); msgContext.setDoingMTOM(TransportUtils.doWriteMTOM(msgContext)); msgContext.setDoingSwA(TransportUtils.doWriteSwA(msgContext)); msgContext.setDoingREST(TransportUtils.isDoingREST(msgContext)); format.setSOAP11(msgContext.isSOAP11()); format.setDoOptimize(msgContext.isDoingMTOM()); format.setDoingSWA(msgContext.isDoingSwA()); format.setCharSetEncoding(TransportUtils.getCharSetEncoding(msgContext)); Object mimeBoundaryProperty = msgContext.getProperty(Constants.Configuration.MIME_BOUNDARY); if (mimeBoundaryProperty != null) { format.setMimeBoundary((String) mimeBoundaryProperty); } return format; }