com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory Java Examples

The following examples show how to use com.sun.xml.internal.ws.api.streaming.XMLStreamWriterFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLCodec.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #2
Source File: XMLCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #3
Source File: XMLCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #4
Source File: XMLCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #5
Source File: XMLCodec.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #6
Source File: XMLCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #7
Source File: XMLCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #8
Source File: XMLCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
            String encoding = (String) packet.invocationProperties
            .get(XMLConstants.OUTPUT_XML_CHARACTER_ENCODING);

    XMLStreamWriter writer = null;

            if (encoding != null && encoding.length() > 0) {
        writer = XMLStreamWriterFactory.create(out, encoding);
    } else {
        writer = XMLStreamWriterFactory.create(out);
    }

    try {
        if (packet.getMessage().hasPayload()){
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.flush();
        }
    } catch (XMLStreamException e) {
        throw new WebServiceException(e);
    }
    return contentType;
}
 
Example #9
Source File: StreamSOAPCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #10
Source File: Packet.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #11
Source File: Packet.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #12
Source File: StreamSOAPCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #13
Source File: Packet.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #14
Source File: StreamSOAPCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #15
Source File: StreamSOAPCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #16
Source File: Packet.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #17
Source File: StreamSOAPCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #18
Source File: Packet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #19
Source File: Packet.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #20
Source File: StreamSOAPCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #21
Source File: Packet.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #22
Source File: StreamSOAPCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #23
Source File: Packet.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
  StringBuilder buf = new StringBuilder();
  buf.append(super.toString());
  String content;
    try {
        Message msg = getMessage();
    if (msg != null) {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    XMLStreamWriter xmlWriter = XMLStreamWriterFactory.create(baos, "UTF-8");
                    msg.copy().writeTo(xmlWriter);
                    xmlWriter.flush();
                    xmlWriter.close();
                    baos.flush();
                    XMLStreamWriterFactory.recycle(xmlWriter);

                    byte[] bytes = baos.toByteArray();
                    //message = Messages.create(XMLStreamReaderFactory.create(null, new ByteArrayInputStream(bytes), "UTF-8", true));
                    content = new String(bytes, "UTF-8");
            } else {
                content = "<none>";
    }
    } catch (Throwable t) {
            throw new WebServiceException(t);
    }
  buf.append(" Content: ").append(content);
  return buf.toString();
}
 
Example #24
Source File: StreamSOAPCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        String encoding = getPacketEncoding(packet);
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
        XMLStreamWriter writer = XMLStreamWriterFactory.create(out, encoding);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
        XMLStreamWriterFactory.recycle(writer);
    }
    return getContentType(packet);
}
 
Example #25
Source File: MtomCodec.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public ContentType encode(Packet packet, OutputStream out) throws IOException {
        ContentTypeImpl ctImpl = (ContentTypeImpl) this.getStaticContentType(packet);
        String boundary = ctImpl.getBoundary();
        String rootId = ctImpl.getRootId();

        if(packet.getMessage() != null){
            try {
                String encoding = getPacketEncoding(packet);
                packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);

                String actionParameter = getActionParameter(packet, version);
                String soapXopContentType = getSOAPXopContentType(encoding, version, actionParameter);

                writeln("--"+boundary, out);
                writeMimeHeaders(soapXopContentType, rootId, out);

                //mtom attachments that need to be written after the root part
                List<ByteArrayBuffer> mtomAttachments = new ArrayList<ByteArrayBuffer>();
                MtomStreamWriterImpl writer = new MtomStreamWriterImpl(
                        XMLStreamWriterFactory.create(out, encoding), mtomAttachments, boundary, mtomFeature);

                packet.getMessage().writeTo(writer);
                XMLStreamWriterFactory.recycle(writer);
                writeln(out);

                for(ByteArrayBuffer bos : mtomAttachments){
                    bos.write(out);
                }

                // now write out the attachments in the message that weren't
                // previously written
                writeNonMtomAttachments(packet.getMessage().getAttachments(),
                        out, boundary);

                //write out the end boundary
                writeAsAscii("--"+boundary, out);
                writeAsAscii("--", out);

            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
        }
        //now create the boundary for next encode() call
//        createConteTypeHeader();
        return ctImpl;
    }
 
Example #26
Source File: XMLStreamWriterFilter.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void onRecycled() {
    XMLStreamWriterFactory.recycle(writer);
    writer = null;
}
 
Example #27
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public ContentType encode(Packet packet, OutputStream out) throws IOException {
        ContentTypeImpl ctImpl = (ContentTypeImpl) this.getStaticContentType(packet);
        String boundary = ctImpl.getBoundary();
        String rootId = ctImpl.getRootId();

        if(packet.getMessage() != null){
            try {
                String encoding = getPacketEncoding(packet);
                packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);

                String actionParameter = getActionParameter(packet, version);
                String soapXopContentType = getSOAPXopContentType(encoding, version, actionParameter);

                writeln("--"+boundary, out);
                writeMimeHeaders(soapXopContentType, rootId, out);

                //mtom attachments that need to be written after the root part
                List<ByteArrayBuffer> mtomAttachments = new ArrayList<ByteArrayBuffer>();
                MtomStreamWriterImpl writer = new MtomStreamWriterImpl(
                        XMLStreamWriterFactory.create(out, encoding), mtomAttachments, boundary, mtomFeature);

                packet.getMessage().writeTo(writer);
                XMLStreamWriterFactory.recycle(writer);
                writeln(out);

                for(ByteArrayBuffer bos : mtomAttachments){
                    bos.write(out);
                }

                // now write out the attachments in the message that weren't
                // previously written
                writeNonMtomAttachments(packet.getMessage().getAttachments(),
                        out, boundary);

                //write out the end boundary
                writeAsAscii("--"+boundary, out);
                writeAsAscii("--", out);

            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
        }
        //now create the boundary for next encode() call
//        createConteTypeHeader();
        return ctImpl;
    }
 
Example #28
Source File: MtomCodec.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
    public ContentType encode(Packet packet, OutputStream out) throws IOException {
        ContentTypeImpl ctImpl = (ContentTypeImpl) this.getStaticContentType(packet);
        String boundary = ctImpl.getBoundary();
        String rootId = ctImpl.getRootId();

        if(packet.getMessage() != null){
            try {
                String encoding = getPacketEncoding(packet);
                packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);

                String actionParameter = getActionParameter(packet, version);
                String soapXopContentType = getSOAPXopContentType(encoding, version, actionParameter);

                writeln("--"+boundary, out);
                writeMimeHeaders(soapXopContentType, rootId, out);

                //mtom attachments that need to be written after the root part
                List<ByteArrayBuffer> mtomAttachments = new ArrayList<ByteArrayBuffer>();
                MtomStreamWriterImpl writer = new MtomStreamWriterImpl(
                        XMLStreamWriterFactory.create(out, encoding), mtomAttachments, boundary, mtomFeature);

                packet.getMessage().writeTo(writer);
                XMLStreamWriterFactory.recycle(writer);
                writeln(out);

                for(ByteArrayBuffer bos : mtomAttachments){
                    bos.write(out);
                }

                // now write out the attachments in the message that weren't
                // previously written
                writeNonMtomAttachments(packet.getMessage().getAttachments(),
                        out, boundary);

                //write out the end boundary
                writeAsAscii("--"+boundary, out);
                writeAsAscii("--", out);

            } catch (XMLStreamException e) {
                throw new WebServiceException(e);
            }
        }
        //now create the boundary for next encode() call
//        createConteTypeHeader();
        return ctImpl;
    }
 
Example #29
Source File: XMLStreamWriterFilter.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void onRecycled() {
    XMLStreamWriterFactory.recycle(writer);
    writer = null;
}
 
Example #30
Source File: XMLStreamWriterFilter.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void onRecycled() {
    XMLStreamWriterFactory.recycle(writer);
    writer = null;
}