/** * Returns the character set encoding scheme. If the value of the charSetEncoding is not set * then the default will be returned. * * @return Returns encoding. */ public String getCharSetEncoding() { return format.getCharSetEncoding(); }
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 String getContentTypeAsString() { String encoding = format.getCharSetEncoding(); String contentType = format.getContentType(); if (encoding != null) { contentType += "; charset=" + encoding; } // action header is not mandated in SOAP 1.2. So putting it, if available if (!msgCtxt.isSOAP11() && (soapActionString != null) && !"".equals(soapActionString.trim()) && !"\"\"".equals(soapActionString.trim())) { contentType = contentType + ";action=\"" + soapActionString + "\";"; } return contentType; }
/** * Different message formats can set their own content types * Eg: JSONFormatter can set the content type as application/json * * @param messageContext * @param format * @param soapAction */ public String getContentType(MessageContext messageContext, OMOutputFormat format, String soapAction) { String contentType = HTTPConstants.MEDIA_TYPE_MULTIPART_FORM_DATA; String encoding = format.getCharSetEncoding(); if (encoding != null) { contentType += "; charset=" + encoding; } contentType = contentType + "; " + "boundary=" + format.getMimeBoundary(); return contentType; }
/** * 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 OMMultipartWriter(OutputStream out, OMOutputFormat format) { this.format = format; writer = format.getMultipartWriterFactory().createMultipartWriter(out, format.getMimeBoundary()); useCTEBase64 = format != null && Boolean.TRUE.equals( format.getProperty(OMOutputFormat.USE_CTE_BASE64_FOR_NON_TEXTUAL_ATTACHMENTS)); String soapContentType; if (format.isSOAP11()) { soapContentType = SOAP11Constants.SOAP_11_CONTENT_TYPE; } else { soapContentType = SOAP12Constants.SOAP_12_CONTENT_TYPE; } if (format.isOptimized()) { rootPartContentType = "application/xop+xml; charset=" + format.getCharSetEncoding() + "; type=\"" + soapContentType + "\""; } else { rootPartContentType = soapContentType + "; charset=" + format.getCharSetEncoding(); } }
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 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[] 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 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()); } }
out.writeInt(revisionID); out.writeBoolean(ACTIVE_OBJECT); if (outputFormat.isOptimized()) { out.writeBoolean(true); out.writeUTF(outputFormat.getContentType()); } else { out.writeBoolean(false); out.writeUTF(outputFormat.getCharSetEncoding()); out.writeUTF(envelope.getNamespace().getNamespaceURI()); if (log.isDebugEnabled()) { log.debug(correlationIDString + ":writeExternal(): " + "optimized=[" + outputFormat.isOptimized() + "] " + "optimizedContentType " + outputFormat.getContentType() + "] " + "charSetEnc=[" + outputFormat.getCharSetEncoding() + "] " + "namespaceURI=[" + envelope.getNamespace().getNamespaceURI() + "]");
log.debug("Creating MTOMXMLStreamWriter"); log.debug("OutputStream =" + outStream.getClass()); log.debug("OMFormat = " + format.toString()); log.debug("preserveAttachments = " + preserveAttachments); this.preserveAttachments = preserveAttachments; String encoding = format.getCharSetEncoding(); if (encoding == null) { //Default encoding is UTF-8 format.setCharSetEncoding(encoding = OMOutputFormat.DEFAULT_CHAR_SET_ENCODING); if (format.isOptimized()) { multipartWriter = new OMMultipartWriter(outStream, format); try { format.getStAXWriterConfiguration(), rootPartOutputStream, encoding), contentIDGenerator, optimizationPolicy); } else { xmlWriter = StAXUtils.createXMLStreamWriter(format.getStAXWriterConfiguration(), outStream, format.getCharSetEncoding()); xmlStreamWriterFilter = format.getXmlStreamWriterFilter(); if (xmlStreamWriterFilter != null) { if (log.isDebugEnabled()) {
if (outputStream instanceof TransportOutputStream) { TransportOutputStream transportOutputStream = (TransportOutputStream) outputStream; String contentType = outputFormat.getContentType(); if (!(outputFormat.isDoingSWA() || outputFormat.isOptimized())) { String charsetEncoding = axiomMessage.getCharsetEncoding(); contentType += "; charset=" + charsetEncoding; if (!(outputFormat.isOptimized()) & outputFormat.isDoingSWA()) { writeSwAMessage(outputStream, outputFormat);
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(); } };
+ UIDGenerator.generateContentId(); OMOutputFormat innerFormat = new OMOutputFormat(format); innerFormat.setMimeBoundary(innerBoundary); innerOutputStream = mpw.writePart("multipart/related; boundary=\"" + innerBoundary + "\"", partCID); attachmentsWriter = new OMMultipartWriter(innerOutputStream, innerFormat);
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())); } }
log.debug("Start getContentType: " + toString()); if (isOptimized()) { ct = this.getContentTypeForMTOM(contentType); } else if (isDoingSWA()) { ct = this.getContentTypeForSwA(contentType); } else { ct = contentType; log.debug("getContentType= {" + ct + "} " + toString());
log.debug("start writeTo()"); log.debug(" preserve=" + preserve); log.debug(" isOptimized=" + format.isOptimized()); log.debug(" isDoingSWA=" + format.isDoingSWA()); log.debug("Setting MTOM optimized Threshold Value on OMOutputFormat"); format.setOptimizedThreshold(optimizedThreshold); if (!(format.isOptimized()) && format.isDoingSWA()) { writeSwAMessage(msgCtxt, out, format, preserve); } else {
public void setCharSetEncoding(String charSetEncoding) { format.setCharSetEncoding(charSetEncoding); }
public String getContentType() { return format.getContentType(); }