public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { messageFormatter.writeTo(messageContext, format, outputStream, preserve); } }
public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { messageFormatter.writeTo(messageContext, format, outputStream, preserve); } }
private void internalWriteRequest(OutputStream outStream) throws IOException { if (gzip) { outStream = new GZIPOutputStream(outStream); } try { messageFormatter.writeTo(messageContext, format, outStream, preserve); if (gzip) { ((GZIPOutputStream) outStream).finish(); } outStream.flush(); } catch (IOException e) { throw AxisFault.makeFault(e); } }
public void writeTo(MessageContext messageContext, OMOutputFormat format, OutputStream outputStream, boolean preserve) throws AxisFault { try { // Writes message as an GZIP stream if (log.isDebugEnabled()) { log.debug("Serialize message in to a GZIP stream"); } OutputStream out = new GZIPOutputStream(outputStream); messageFormatter.writeTo(messageContext, format, out, preserve); try { out.flush(); out.close(); } catch (IOException e) { handleException("Error closing message stream", e); } } catch (IOException e) { handleException("Error getting GZIP output stream", e); } }
/** * Write the stream to a temporary storage and calculate the content length * * @throws IOException if an exception occurred while writing data */ private OverflowBlob setStreamAsTempData(MessageFormatter messageFormatter,MessageContext msgContext,OMOutputFormat format) throws IOException { OverflowBlob serialized = new OverflowBlob(256, 4096, "http-nio_", ".dat"); OutputStream out = serialized.getOutputStream(); try { messageFormatter.writeTo(msgContext, format, out, false); } finally { out.close(); } return serialized; }
private void writeOut(MessageContext msgContext, Socket socket, String contentType) throws IOException { MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(msgContext); OMOutputFormat format = BaseUtils.getOMOutputFormat(msgContext); format.setContentType(contentType); OutputStream out = socket.getOutputStream(); messageFormatter.writeTo(msgContext, format, out, false); out.flush(); }
/** * Format the messages when the messages are sent to the kafka broker */ public static String formatMessage( org.apache.axis2.context.MessageContext messageContext) throws AxisFault { OMOutputFormat format = BaseUtils.getOMOutputFormat(messageContext); MessageFormatter messageFormatter = MessageProcessorSelector.getMessageFormatter(messageContext); ; StringWriter stringWriter = new StringWriter(); OutputStream out = new WriterOutputStream(stringWriter, format.getCharSetEncoding()); try { messageFormatter.writeTo(messageContext, format, out, true); } catch (IOException e) { throw new AxisFault("The Error occurs while formatting the message", e); } finally { try { out.close(); } catch (Exception e) { throw new AxisFault("The Error occurs while closing the output stream", e); } } return stringWriter.toString(); } }
msgFormatter.writeTo(mc, outputFormat, bos, true); // Preserve the original message
msgFormatter.writeTo(mc, outputFormat, bos, true); // Preserve the original message
public void writeRequest(OutputStream outStream) throws IOException { Object gzip = messageContext.getOptions().getProperty(HTTPConstants.MC_GZIP_REQUEST); if (gzip != null && JavaUtils.isTrueExplicitly(gzip) && chunked) { outStream = new GZIPOutputStream(outStream); } try { if (chunked) { messageFormatter.writeTo(messageContext, format, outStream, isAllowedRetry); } else { if (bytes == null) { bytes = messageFormatter.getBytes(messageContext, format); } outStream.write(bytes); } if (outStream instanceof GZIPOutputStream) { ((GZIPOutputStream) outStream).finish(); } outStream.flush(); } catch (FactoryConfigurationError e) { throw AxisFault.makeFault(e); } catch (IOException e) { throw AxisFault.makeFault(e); } }
OMOutputFormat format = PassThroughTransportUtils.getOMOutputFormat(responseMsgContext); ByteArrayOutputStream out = new ByteArrayOutputStream(); formatter.writeTo(responseMsgContext, format, out, preserveStream); TreeSet<String> header = new TreeSet<String>(); header.add(String.valueOf(out.toByteArray().length));
/** * Write the stream to a temporary storage and calculate the content length * * @param entity HTTPEntity * @throws IOException if an exception occurred while writing data */ private void setStreamAsTempData(BasicHttpEntity entity) throws IOException { OverflowBlob serialized = new OverflowBlob(256, 4096, "http-nio_", ".dat"); OutputStream out = serialized.getOutputStream(); try { messageFormatter.writeTo(msgContext, format, out, true); } finally { out.close(); } msgContext.setProperty(NhttpConstants.SERIALIZED_BYTES, serialized); entity.setContentLength(serialized.getLength()); }
} else { if (chunked) { messageFormatter.writeTo(msgContext, format, out, false); } else { writeMessageFromTempData(out);
/** * Write the stream to a temporary storage and calculate the content length * @param entity HTTPEntity * @param messageFormatter message formatter * @param msgContext current message context * @param format message format * @throws IOException if an exception occurred while writing data */ private void setStreamAsTempData(BasicHttpEntity entity, MessageFormatter messageFormatter, MessageContext msgContext, OMOutputFormat format) throws IOException { TemporaryData serialized = new TemporaryData(256, 4096, "http-nio_", ".dat"); OutputStream out = serialized.getOutputStream(); try { messageFormatter.writeTo(msgContext, format, out, true); } finally { out.close(); } msgContext.setProperty(NhttpConstants.SERIALIZED_BYTES, serialized); entity.setContentLength(serialized.getLength()); }
format.setContentType(udpOutInfo.getContentType()); ByteArrayOutputStream out = new ByteArrayOutputStream(); messageFormatter.writeTo(msgContext, format, out, false); byte[] payload = out.toByteArray(); try {
private MqttMessage createMqttMessage(MessageContext messageContext) { OMOutputFormat format = BaseUtils.getOMOutputFormat(messageContext); MessageFormatter messageFormatter; try { messageFormatter = MessageProcessorSelector.getMessageFormatter(messageContext); } catch (AxisFault axisFault) { throw new AxisMqttException("Unable to get the message formatter to use"); } OutputStream out; StringWriter sw = new StringWriter(); try { out = new WriterOutputStream(sw, format.getCharSetEncoding()); } catch (UnsupportedCharsetException ex) { throw new AxisMqttException("Unsupported encoding " + format.getCharSetEncoding(), ex); } try { messageFormatter.writeTo(messageContext, format, out, true); out.close(); } catch (IOException e) { throw new AxisMqttException("IO Error while creating BytesMessage", e); } MqttMessage mqttMessage = new MqttMessage(); mqttMessage.setPayload(sw.toString().getBytes()); return mqttMessage; } }
MessageFormatter formatter = MessageProcessorSelector.getMessageFormatter(requestMsgCtx); OMOutputFormat format = PassThroughTransportUtils.getOMOutputFormat(requestMsgCtx); formatter.writeTo(requestMsgCtx, format, out, false); OutputStream _out = pipe.getOutputStream(); IOUtils.write(out.toByteArray(), _out);
private void sendUsingOutputStream(MessageContext msgContext) throws AxisFault { OMOutputFormat format = NhttpUtil.getOMOutputFormat(msgContext); MessageFormatter messageFormatter = MessageFormatterDecoratorFactory.createMessageFormatterDecorator(msgContext); OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT); if (msgContext.isServerSide()) { OutTransportInfo transportInfo = (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO); if (transportInfo != null) { transportInfo.setContentType( messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction())); } else { throw new AxisFault(Constants.OUT_TRANSPORT_INFO + " has not been set"); } } try { messageFormatter.writeTo(msgContext, format, out, false); out.close(); } catch (IOException e) { handleException("IO Error sending response message", e); } }
private void sendUsingOutputStream(MessageContext msgContext) throws AxisFault { OMOutputFormat format = NhttpUtil.getOMOutputFormat(msgContext); MessageFormatter messageFormatter = MessageFormatterDecoratorFactory.createMessageFormatterDecorator(msgContext); OutputStream out = (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT); if (msgContext.isServerSide()) { OutTransportInfo transportInfo = (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO); if (transportInfo != null) { transportInfo.setContentType( messageFormatter.getContentType(msgContext, format, msgContext.getSoapAction())); } else { throw new AxisFault(Constants.OUT_TRANSPORT_INFO + " has not been set"); } } try { messageFormatter.writeTo(msgContext, format, out, false); out.close(); } catch (IOException e) { handleException("IO Error sending response message", e); } }
responseFile.getContent().getOutputStream(append)); try { messageFormatter.writeTo(msgContext, format, os, false); } finally { os.close();