Search in sources :

Example 1 with MessageDataSource

use of com.sun.xml.ws.encoding.xml.XMLMessage.MessageDataSource in project metro-jax-ws by eclipse-ee4j.

the class XMLHTTPBindingCodec method getStaticContentType.

@Override
public ContentType getStaticContentType(Packet packet) {
    ContentType ct;
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource) packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource()) {
            ct = getStaticContentType(mds);
            return (ct != null) ? // _adaptingContentType.set(packet, ct)
            setAcceptHeader(packet, ct) : null;
        }
    }
    ct = super.getStaticContentType(packet);
    return (ct != null) ? // _adaptingContentType.set(packet, ct)
    setAcceptHeader(packet, ct) : null;
}
Also used : ContentType(com.sun.xml.ws.api.pipe.ContentType) MessageDataSource(com.sun.xml.ws.encoding.xml.XMLMessage.MessageDataSource)

Example 2 with MessageDataSource

use of com.sun.xml.ws.encoding.xml.XMLMessage.MessageDataSource in project metro-jax-ws by eclipse-ee4j.

the class XMLHTTPBindingCodec method encode.

private ContentType encode(MessageDataSource mds, OutputStream out) {
    try {
        final boolean isFastInfoset = XMLMessage.isFastInfoset(mds.getDataSource().getContentType());
        DataSource ds = transformDataSource(mds.getDataSource(), isFastInfoset, useFastInfosetForEncoding, features);
        InputStream is = ds.getInputStream();
        byte[] buf = new byte[1024];
        int count;
        while ((count = is.read(buf)) != -1) {
            out.write(buf, 0, count);
        }
        return new ContentTypeImpl(ds.getContentType());
    } catch (IOException ioe) {
        throw new WebServiceException(ioe);
    }
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) InputStream(java.io.InputStream) IOException(java.io.IOException) MessageDataSource(com.sun.xml.ws.encoding.xml.XMLMessage.MessageDataSource) DataSource(jakarta.activation.DataSource)

Aggregations

MessageDataSource (com.sun.xml.ws.encoding.xml.XMLMessage.MessageDataSource)2 ContentType (com.sun.xml.ws.api.pipe.ContentType)1 DataSource (jakarta.activation.DataSource)1 WebServiceException (jakarta.xml.ws.WebServiceException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1