Java源码示例:com.sun.xml.internal.ws.api.pipe.ContentType

示例1
public ContentType encode(Packet packet, OutputStream out) {
    Message message = packet.getMessage();
    if (message != null && message.hasPayload()) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.writeEndDocument();
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }

    return _contentType;
}
 
示例2
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
示例3
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);

    if (hasAttachments) {
        String boundary = "uuid:" + UUID.randomUUID().toString();
        String boundaryParameter = "boundary=\"" + boundary + "\"";
        // TODO use primaryEncoder to get type
        String messageContentType =  MULTIPART_RELATED_MIME_TYPE +
                "; type=\"" + rootCodec.getMimeType() + "\"; " +
                boundaryParameter;
        ContentTypeImpl impl = new ContentTypeImpl(messageContentType, packet.soapAction, null);
        impl.setBoundary(boundary);
        impl.setBoundaryParameter(boundaryParameter);
        packet.setContentType(impl);
        return impl;
    } else {
        ct = rootCodec.getStaticContentType(packet);
        packet.setContentType(ct);
        return ct;
    }
}
 
示例4
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
示例5
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
示例6
@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)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
示例7
public void decode(InputStream in, String contentType, Packet packet, AttachmentSet att ) throws IOException {
    List<String> expectedContentTypes = getExpectedContentTypes();
    if (contentType != null && !isContentTypeSupported(contentType,expectedContentTypes)) {
        throw new UnsupportedMediaException(contentType, expectedContentTypes);
    }
    com.oracle.webservices.internal.api.message.ContentType pct = packet.getInternalContentType();
    ContentTypeImpl cti = (pct != null && pct instanceof ContentTypeImpl) ?
            (ContentTypeImpl)pct : new ContentTypeImpl(contentType);
    String charset = cti.getCharSet();
    if (charset != null && !Charset.isSupported(charset)) {
        throw new UnsupportedMediaException(charset);
    }
    if (charset != null) {
        packet.invocationProperties.put(DECODED_MESSAGE_CHARSET, charset);
    } else {
        packet.invocationProperties.remove(DECODED_MESSAGE_CHARSET);
    }
    packet.setMessage(streamDecoder.decode(in, charset, att, soapVersion));
}
 
示例8
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);
    }
}
 
示例9
@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)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
示例10
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;
}
 
示例11
@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)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
示例12
public ContentType encode(Packet packet, OutputStream out) {
    Message message = packet.getMessage();
    if (message != null && message.hasPayload()) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            writer.writeStartDocument();
            packet.getMessage().writePayloadTo(writer);
            writer.writeEndDocument();
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }

    return _contentType;
}
 
示例13
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;
}
 
示例14
public static ContentType getStaticContentTypeStatic(Packet packet, SOAPVersion version) {
    ContentType ct = (ContentType) packet.getInternalContentType();
    if ( ct != null ) return ct;

    String uuid = UUID.randomUUID().toString();
    String boundary = "uuid:" + uuid;
    String rootId = "<rootpart*"+uuid+"@example.jaxws.sun.com>";
    String soapActionParameter = SOAPVersion.SOAP_11.equals(version) ?  null : createActionParameter(packet);

    String boundaryParameter = "boundary=\"" + boundary +"\"";
    String messageContentType = MULTIPART_RELATED_MIME_TYPE +
            ";start=\""+rootId +"\"" +
            ";type=\"" + XOP_XML_MIME_TYPE + "\";" +
            boundaryParameter +
            ";start-info=\"" + version.contentType +
            (soapActionParameter == null? "" : soapActionParameter) +
            "\"";

    ContentTypeImpl ctImpl = SOAPVersion.SOAP_11.equals(version) ?
            new ContentTypeImpl(messageContentType, (packet.soapAction == null)?"":packet.soapAction, null) :
            new ContentTypeImpl(messageContentType, null, null);
    ctImpl.setBoundary(boundary);
    ctImpl.setRootId(rootId);
    packet.setContentType(ctImpl);
    return ctImpl;
}
 
示例15
@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)
                ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
                : null;
        }
    }

    ct = super.getStaticContentType(packet);
    return (ct != null)
        ? setAcceptHeader(packet, ct) //_adaptingContentType.set(packet, ct)
        : null;
}
 
示例16
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
示例17
protected ContentType getContentType(String soapAction) {
    if (soapAction == null || soapAction.length() == 0) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(_defaultContentType.getContentType(), soapAction);
    }
}
 
示例18
protected ContentType getContentType(String soapAction) {
    if (soapAction == null) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(
                _defaultContentType.getContentType() + ";action=\""+soapAction+"\"");
    }
}
 
示例19
private ContentTypeImpl setAcceptHeader(Packet p, ContentType c) {
    ContentTypeImpl ctImpl = (ContentTypeImpl)c;
    if (p.contentNegotiation == ContentNegotiation.optimistic
            || p.contentNegotiation == ContentNegotiation.pessimistic) {
        ctImpl.setAcceptHeader(fiXmlAccept);
    } else {
        ctImpl.setAcceptHeader(xmlAccept);
    }
    p.setContentType(ctImpl);
    return ctImpl;
}
 
示例20
protected ContentType getContentType(String soapAction) {
    if (soapAction == null) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(
                _defaultContentType.getContentType() + ";action=\""+soapAction+"\"");
    }
}
 
示例21
private ContentType getStaticContentType(MessageDataSource mds) {
    final String contentType = mds.getDataSource().getContentType();
    final boolean isFastInfoset = XMLMessage.isFastInfoset(contentType);

    if (!requiresTransformationOfDataSource(isFastInfoset,
            useFastInfosetForEncoding)) {
        return new ContentTypeImpl(contentType);
    } else {
        return null;
    }
}
 
示例22
private ContentTypeImpl setAcceptHeader(Packet p, ContentType c) {
    ContentTypeImpl ctImpl = (ContentTypeImpl)c;
    if (p.contentNegotiation == ContentNegotiation.optimistic
            || p.contentNegotiation == ContentNegotiation.pessimistic) {
        ctImpl.setAcceptHeader(fiXmlAccept);
    } else {
        ctImpl.setAcceptHeader(xmlAccept);
    }
    p.setContentType(ctImpl);
    return ctImpl;
}
 
示例23
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
示例24
protected ContentType getContentType(String soapAction) {
    if (soapAction == null || soapAction.length() == 0) {
        return _defaultContentType;
    } else {
        return new ContentTypeImpl(_defaultContentType.getContentType(), soapAction);
    }
}
 
示例25
public ContentType encode(Packet packet, OutputStream out) {
    if (packet.getMessage() != null) {
        final XMLStreamWriter writer = getXMLStreamWriter(out);
        try {
            packet.getMessage().writeTo(writer);
            writer.flush();
        } catch (XMLStreamException e) {
            throw new WebServiceException(e);
        }
    }
    return getContentType(packet.soapAction);
}
 
示例26
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);
}
 
示例27
@Override
public ContentType encode(Packet packet, OutputStream out) throws IOException {
    if (packet.getInternalMessage() instanceof MessageDataSource) {
        final MessageDataSource mds = (MessageDataSource)packet.getInternalMessage();
        if (mds.hasUnconsumedDataSource())
            return setAcceptHeader(packet, encode(mds, out));
    }

    return setAcceptHeader(packet, super.encode(packet, out));
}
 
示例28
public ContentType encode(Packet packet, WritableByteChannel buffer) {
    preEncode(packet);
    ContentType ct = getEncoder(packet).encode(packet, buffer);
    ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
    postEncode();
    return ct;
}
 
示例29
public ContentType encode(Packet packet, WritableByteChannel buffer) {
    preEncode(packet);
    ContentType ct = getEncoder(packet).encode(packet, buffer);
    ct = setAcceptHeader(packet, (ContentTypeImpl)ct);
    postEncode();
    return ct;
}
 
示例30
private ContentType getStaticContentType(MessageDataSource mds) {
    final String contentType = mds.getDataSource().getContentType();
    final boolean isFastInfoset = XMLMessage.isFastInfoset(contentType);

    if (!requiresTransformationOfDataSource(isFastInfoset,
            useFastInfosetForEncoding)) {
        return new ContentTypeImpl(contentType);
    } else {
        return null;
    }
}