Package com.sun.xml.ws.api.pipe

Examples of com.sun.xml.ws.api.pipe.ContentType


        MyClosedCallback callback = new MyClosedCallback(request);
        LocalConnectionImpl con = new LocalConnectionImpl(baseURI,reqHeaders,callback);
        callback.setConnection(con);
        // Calling getStaticContentType sets some internal state in the codec
        // TODO : need to fix this properly in Codec
        ContentType contentType = codec.getStaticContentType(request);
        String requestContentType;
        if (contentType != null) {
            requestContentType = contentType.getContentType();
            codec.encode(request, con.getOutput());
        } else {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            contentType = codec.encode(request, baos);
            requestContentType = contentType.getContentType();
            baos.writeTo(con.getOutput());
        }
        callback.setContentType(contentType);
        reqHeaders.put("Content-Type", Collections.singletonList(requestContentType));

        String requestAccept = contentType.getAcceptHeader();
        if (contentType.getAcceptHeader() != null) {
            reqHeaders.put("Accept", Collections.singletonList(requestAccept));
        }

        if (dump) {
            dump(con, "request", reqHeaders);
View Full Code Here



            LocalConnectionImpl con = new LocalConnectionImpl(baseURI,reqHeaders);
            // Calling getStaticContentType sets some internal state in the codec
            // TODO : need to fix this properly in Codec
            ContentType contentType = codec.getStaticContentType(request);
            String requestContentType;
            if (contentType != null) {
                requestContentType = contentType.getContentType();
                codec.encode(request, con.getOutput());
            } else {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                contentType = codec.encode(request, baos);
                requestContentType = contentType.getContentType();
                baos.writeTo(con.getOutput());
            }
            reqHeaders.put("Content-Type", Collections.singletonList(requestContentType));

            String requestAccept = contentType.getAcceptHeader();
            if (contentType.getAcceptHeader() != null) {
                reqHeaders.put("Accept", Collections.singletonList(requestAccept));
            }

            writeSOAPAction(reqHeaders, contentType.getSOAPActionHeader(), request);
           
            if(dump)
                dump(con,"request",reqHeaders);

            adapter.handle(con);
View Full Code Here

                }
                os.close();
                return;
            }

            ContentType contentType = codec.getStaticContentType(packet);
            if (contentType != null) {
                con.setContentTypeResponseHeader(contentType.getContentType());
                OutputStream os = con.getProtocol().contains("1.1") ? con.getOutput() : new Http10OutputStream(con);
                if (dump || LOGGER.isLoggable(Level.FINER)) {
                    ByteArrayBuffer buf = new ByteArrayBuffer();
                    codec.encode(packet, buf);
                    dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
                    buf.writeTo(os);
                } else {
                    codec.encode(packet, os);
                }
                os.close();
            } else {

                ByteArrayBuffer buf = new ByteArrayBuffer();
                contentType = codec.encode(packet, buf);
                con.setContentTypeResponseHeader(contentType.getContentType());
                if (dump || LOGGER.isLoggable(Level.FINER)) {
                    dump(buf, "HTTP response " + con.getStatus(), con.getResponseHeaders());
                }
                OutputStream os = con.getOutput();
                buf.writeTo(os);
View Full Code Here

        String rootId = ctImpl.getRootId();
        boolean hasAttachments = (boundary != null);
        Codec rootCodec = getMimeRootCodec(packet);
        if (hasAttachments) {
            writeln("--"+boundary, out);
            ContentType ct = rootCodec.getStaticContentType(packet);
            String ctStr = (ct != null) ? ct.getContentType() : rootCodec.getMimeType();
            if (rootId != null) writeln("Content-ID: " + rootId, out);
            writeln("Content-Type: " + ctStr, out);
            writeln(out);
        }
        ContentType primaryCt = rootCodec.encode(packet, out);

        if (hasAttachments) {
            writeln(out);
            // Encode all the attchments
            for (Attachment att : msg.getAttachments()) {
View Full Code Here

            }
        }
    }

    public ContentType getStaticContentType(Packet packet) {
        ContentType ct = (ContentType) packet.getInternalContentType();
        if ( ct != null ) return ct;
        Message msg = packet.getMessage();
        boolean hasAttachments = !msg.getAttachments().isEmpty();
        Codec rootCodec = getMimeRootCodec(packet);
View Full Code Here

    public String getMimeType() {
        return null;
    }
   
    public ContentType getStaticContentType(Packet packet) {
        ContentType toAdapt = getEncoder(packet).getStaticContentType(packet);
        return setAcceptHeader(packet, (ContentTypeImpl)toAdapt);
    }
View Full Code Here

        return setAcceptHeader(packet, (ContentTypeImpl)toAdapt);
    }
   
    public ContentType encode(Packet packet, OutputStream out) throws IOException {
       preEncode(packet);
       ContentType ct = getEncoder(packet).encode(packet, out);
       ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
       postEncode();
       return ct;
    }
View Full Code Here

       return ct;
    }
   
    public ContentType encode(Packet packet, WritableByteChannel buffer) {
        preEncode(packet);
        ContentType ct = getEncoder(packet).encode(packet, buffer);
        ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
        postEncode();
        return ct;
    }
View Full Code Here

        return null;
    }
   
    @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)
View Full Code Here

               
                p.getMessage().getAttachments();
                codec.getStaticContentType(p);
               
                ByteArrayBuffer bos = new ByteArrayBuffer();
                ContentType ct = codec.encode(p, bos);
                return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());
            } else if (!isFastInfoset && useFastInfoset) {
                // Convert from XML to Fast Infoset
                Codec codec = new XMLHTTPBindingCodec(f);
                Packet p = new Packet();
                codec.decode(in.getInputStream(), in.getContentType(), p);
               
                p.contentNegotiation = ContentNegotiation.optimistic;
                p.getMessage().getAttachments();
                codec.getStaticContentType(p);
               
                ByteArrayBuffer bos = new ByteArrayBuffer();
                com.sun.xml.ws.api.pipe.ContentType ct = codec.encode(p, bos);
                return XMLMessage.createDataSource(ct.getContentType(), bos.newInputStream());               
            }
        } catch(Exception ex) {
            throw new WebServiceException(ex);
        }
       
View Full Code Here

TOP

Related Classes of com.sun.xml.ws.api.pipe.ContentType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.