Java Code Examples for com.sun.xml.internal.ws.api.message.Packet#setContentType()

The following examples show how to use com.sun.xml.internal.ws.api.message.Packet#setContentType() . 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: MtomCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: MimeCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 3
Source File: MtomCodec.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: MtomCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 6
Source File: MtomCodec.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 7
Source File: MtomCodec.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example 8
Source File: MimeCodec.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
    }
}
 
Example 9
Source File: MtomCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example 10
Source File: SOAPBindingCodec.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example 11
Source File: SOAPBindingCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example 12
Source File: XMLHTTPBindingCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: XMLHTTPBindingCodec.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: SOAPBindingCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example 15
Source File: XMLHTTPBindingCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 16
Source File: MtomCodec.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example 17
Source File: MtomCodec.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}
 
Example 18
Source File: XMLHTTPBindingCodec.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example 19
Source File: SOAPBindingCodec.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void decode(InputStream in, String contentType, Packet packet) throws IOException {
    if (contentType == null) {
        contentType = xmlMimeType;
    }
    packet.setContentType(new ContentTypeImpl(contentType));
    preDecode(packet);
    try {
        if(isMultipartRelated(contentType))
            // parse the multipart portion and then decide whether it's MTOM or SwA
            super.decode(in, contentType, packet);
        else if(isFastInfoset(contentType)) {
            if (!ignoreContentNegotiationProperty && packet.contentNegotiation == ContentNegotiation.none)
                throw noFastInfosetForDecoding();

            useFastInfosetForEncoding = true;
            fiSoapCodec.decode(in, contentType, packet);
        } else
            xmlSoapCodec.decode(in, contentType, packet);
    } catch(RuntimeException we) {
        if (we instanceof ExceptionHasMessage || we instanceof UnsupportedMediaException) {
            throw we;
        } else {
            throw new MessageCreationException(version, we);
        }
    }
    postDecode(packet);
}
 
Example 20
Source File: MtomCodec.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void decode(MimeMultipartParser mpp, Packet packet) throws IOException {
    //TODO shouldn't we check for SOAP1.1/SOAP1.2 and throw
    //TODO UnsupportedMediaException like StreamSOAPCodec
    String charset = null;
    String ct = mpp.getRootPart().getContentType();
    if (ct != null) {
        charset = new ContentTypeImpl(ct).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);
    }

    // we'd like to reuse those reader objects but unfortunately decoder may be reused
    // before the decoded message is completely used.
    XMLStreamReader mtomReader = new MtomXMLStreamReaderEx( mpp,
        XMLStreamReaderFactory.create(null, mpp.getRootPart().asInputStream(), charset, true)
    );

    packet.setMessage(codec.decode(mtomReader, new MimeAttachmentSet(mpp)));
    packet.setMtomFeature(mtomFeature);
    packet.setContentType(mpp.getContentType());
}