private void writeSwAMessage(OutputStream outputStream, OMOutputFormat format) throws XMLStreamException, UnsupportedEncodingException { StringWriter writer = new StringWriter(); SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope(); if (payloadCaching) { envelope.serialize(writer, format); } else { envelope.serializeAndConsume(writer, format); } MIMEOutputUtils.writeSOAPWithAttachmentsMessage(writer, outputStream, attachments, format); }
/** * Converts the SOAP Envelope element from the Axis2 representation to the standard DOM representation. * * @param mc The MessageContext representing the SOAP message * @return A {@link Document} object that represents to the SOAP envelope element contained in the message, or<br> * <code>null</code> when the SOAP envelope can not be converted to a standard DOM representation */ public static Document convertAxiomSOAPEnvToDOM(final MessageContext mc) { try { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); mc.getEnvelope().serialize(baos); final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); return factory.newDocumentBuilder().parse(bais); } catch (final Exception e) { // If anything goes wrong converting the document, just return null return null; } }
/** * Converts a given AXIOM {@link org.apache.axiom.soap.SOAPEnvelope} to a {@link Document}. * * @param envelope the SOAP envelope to be converted * @return the converted document * @throws IllegalArgumentException in case of errors * @see org.apache.rampart.util.Axis2Util.getDocumentFromSOAPEnvelope(SOAPEnvelope, boolean) */ public static Document toDocument(SOAPEnvelope envelope) { try { if (envelope instanceof Element) { return ((Element) envelope).getOwnerDocument(); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); envelope.build(); envelope.serialize(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); return documentBuilderFactory.newDocumentBuilder().parse(bis); } } catch (Exception ex) { throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex); } }
private void writeSwAMessage(OutputStream outputStream, OMOutputFormat format) throws XMLStreamException, UnsupportedEncodingException { StringWriter writer = new StringWriter(); SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope(); if (payloadCaching) { envelope.serialize(writer, format); } else { envelope.serializeAndConsume(writer, format); } try { OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format); Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), format.getCharSetEncoding()); rootPartWriter.write(writer.toString()); rootPartWriter.close(); // Get the collection of ids associated with the attachments for (String id: attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); } catch (IOException ex) { throw new OMException("Error writing SwA message", ex); } }
/** * Converts a given AXIOM {@link org.apache.axiom.soap.SOAPEnvelope} to a {@link Document}. * * @param envelope the SOAP envelope to be converted * @return the converted document * @throws IllegalArgumentException in case of errors */ public static Document toDocument(SOAPEnvelope envelope) { try { if (envelope instanceof Element) { return ((Element) envelope).getOwnerDocument(); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); envelope.build(); envelope.serialize(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); return documentBuilderFactory.newDocumentBuilder().parse(bis); } } catch (Exception ex) { throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex); } }
private void writeSwAMessage(OutputStream outputStream, OMOutputFormat format) throws XMLStreamException, UnsupportedEncodingException { StringWriter writer = new StringWriter(); SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope(); if (payloadCaching) { envelope.serialize(writer, format); } else { envelope.serializeAndConsume(writer, format); } try { OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format); Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), format.getCharSetEncoding()); rootPartWriter.write(writer.toString()); rootPartWriter.close(); // Get the collection of ids associated with the attachments for (String id: attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); } catch (IOException ex) { throw new OMException("Error writing SwA message", ex); } }
/** * Converts a given AXIOM {@link org.apache.axiom.soap.SOAPEnvelope} to a {@link Document}. * * @param envelope the SOAP envelope to be converted * @return the converted document * @throws IllegalArgumentException in case of errors */ public static Document toDocument(SOAPEnvelope envelope) { try { if (envelope instanceof Element) { return ((Element) envelope).getOwnerDocument(); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); envelope.build(); envelope.serialize(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); return documentBuilderFactory.newDocumentBuilder().parse(bis); } } catch (Exception ex) { throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex); } }
private void writeSwAMessage(OutputStream outputStream, OMOutputFormat format) throws XMLStreamException, UnsupportedEncodingException { StringWriter writer = new StringWriter(); SOAPEnvelope envelope = axiomMessage.getSOAPEnvelope(); if (payloadCaching) { envelope.serialize(writer, format); } else { envelope.serializeAndConsume(writer, format); } try { OMMultipartWriter mpw = new OMMultipartWriter(outputStream, format); Writer rootPartWriter = new OutputStreamWriter(mpw.writeRootPart(), format.getCharSetEncoding()); rootPartWriter.write(writer.toString()); rootPartWriter.close(); // Get the collection of ids associated with the attachments for (String id: attachments.getAllContentIDs()) { mpw.writePart(attachments.getDataHandler(id), id); } mpw.complete(); } catch (IOException ex) { throw new OMException("Error writing SwA message", ex); } }
/** * Converts a given AXIOM {@link org.apache.axiom.soap.SOAPEnvelope} to a {@link Document}. * * @param envelope the SOAP envelope to be converted * @return the converted document * @throws IllegalArgumentException in case of errors */ public static Document toDocument(SOAPEnvelope envelope) { try { if (envelope instanceof Element) { return ((Element) envelope).getOwnerDocument(); } else { ByteArrayOutputStream bos = new ByteArrayOutputStream(); envelope.build(); envelope.serialize(bos); ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactoryUtils.newInstance(); documentBuilderFactory.setNamespaceAware(true); return documentBuilderFactory.newDocumentBuilder().parse(bis); } } catch (Exception ex) { throw new IllegalArgumentException("Error in converting SOAP Envelope to Document", ex); } }
format.setCharSetEncoding("UTF-8"); request.serialize(out); out.close(); final boolean isFault = conn.getResponseCode() != 200;
envelope.serialize(new NullOutputStream());
resEnv.serialize(res.getOutputStream()); res.getOutputStream().flush(); } catch (Exception e) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(); env.build(); env.serialize(baos); ByteArrayInputStream bais = new ByteArrayInputStream(baos .toByteArray());
resEnv.serialize(response.getOutputStream()); response.getOutputStream().flush(); } catch (Exception e) {
writeError(factory, binding, body, error); writeBody(factory, binding, body, result); envelope.serialize(out); bytesWritten = out.getCount(); } catch (Exception e) {
synCtx.getEnvelope().serialize(outStream); response.setResponseEnvelope(outStream.toByteArray()); } catch (XMLStreamException e) {
FixedByteArrayOutputStream fbaos = new FixedByteArrayOutputStream(maxMessageSize); try { MessageHelper.cloneSOAPEnvelope(synCtx.getEnvelope()).serialize(fbaos); } catch (XMLStreamException e) { handleException("Error in checking the message size", e, synCtx);