com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl Java Examples

The following examples show how to use com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl. 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: SOAPPartImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    org.w3c.dom.Node soapEnvelope = document.findIfPresent(envelopeChildElement);
    if (soapEnvelope == null || soapEnvelope instanceof Envelope) {
        envelope = (EnvelopeImpl) soapEnvelope;
    } else if (document.find(envelopeChildElement) == null) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) document.find(envelopeChildElement);
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #2
Source File: SOAPPart1_2Impl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #3
Source File: SOAPPart1_1Impl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #4
Source File: SOAPPartImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #5
Source File: SOAPPart1_2Impl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #6
Source File: SOAPPart1_1Impl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #7
Source File: SOAPPartImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #8
Source File: SOAPPart1_2Impl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #9
Source File: SOAPPart1_1Impl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #10
Source File: SOAPPartImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #11
Source File: SOAPPart1_2Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #12
Source File: SOAPPart1_1Impl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #13
Source File: SOAPPartImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #14
Source File: SOAPPartImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public SOAPEnvelope getEnvelope() throws SOAPException {

    // If there is no SOAP envelope already created, then create
    // one from a source if one exists. If there is a newer source
    // then use that source.

    if (sourceWasSet)
          sourceWasSet = false;

    lookForEnvelope();
    if (envelope != null) {
        if (source != null) { // there's a newer source, use it
            document.removeChild(envelope);
            envelope = createEnvelopeFromSource();
        }
    } else if (source != null) {
        envelope = createEnvelopeFromSource();
    } else {
        envelope = createEmptyEnvelope(null);
        document.insertBefore(((EnvelopeImpl) envelope).getDomElement(), null);
    }
    return envelope;
}
 
Example #15
Source File: SOAPPart1_2Impl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #16
Source File: SOAPPart1_1Impl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #17
Source File: SOAPPartImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #18
Source File: SOAPPart1_2Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #19
Source File: SOAPPart1_1Impl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #20
Source File: SOAPPartImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #21
Source File: SOAPPart1_2Impl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #22
Source File: SOAPPart1_1Impl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #23
Source File: SOAPPartImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
protected void lookForEnvelope() throws SOAPException {
    Element envelopeChildElement = document.doGetDocumentElement();
    if (envelopeChildElement == null || envelopeChildElement instanceof Envelope) {
        envelope = (EnvelopeImpl) envelopeChildElement;
    } else if (!(envelopeChildElement instanceof ElementImpl)) {
        log.severe("SAAJ0512.soap.incorrect.factory.used");
        throw new SOAPExceptionImpl("Unable to create envelope: incorrect factory used during tree construction");
    } else {
        ElementImpl soapElement = (ElementImpl) envelopeChildElement;
        if (soapElement.getLocalName().equalsIgnoreCase("Envelope")) {
            String prefix = soapElement.getPrefix();
            String uri = (prefix == null) ? soapElement.getNamespaceURI() : soapElement.getNamespaceURI(prefix);
            if(!uri.equals(NameImpl.SOAP11_NAMESPACE) && !uri.equals(NameImpl.SOAP12_NAMESPACE)) {
                log.severe("SAAJ0513.soap.unknown.ns");
                throw new SOAPVersionMismatchException("Unable to create envelope from given source because the namespace was not recognized");
            }
        } else {
            log.severe("SAAJ0514.soap.root.elem.not.named.envelope");
            throw new SOAPExceptionImpl(
                "Unable to create envelope from given source because the root element is not named \"Envelope\"");
        }
    }
}
 
Example #24
Source File: SOAPPart1_2Impl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope = (EnvelopeImpl)EnvelopeFactory.createEnvelope(tmp, this);
    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        log.severe("SAAJ0415.ver1_2.msg.invalid.soap1.2");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.2 Message");
    }

    if (parser != null) { //can be null if source was a DomSource and not StreamSource
        if (!omitXmlDecl) {
            envelope.setOmitXmlDecl("no");
            envelope.setXmlDecl(parser.getXmlDeclaration());
            envelope.setCharsetEncoding(parser.getEncoding());
        }
    }
    return envelope;

}
 
Example #25
Source File: SOAPPart1_1Impl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
protected Envelope createEnvelopeFromSource() throws SOAPException {
    // Record the presence of xml declaration before the envelope gets
    // created.
    XMLDeclarationParser parser = lookForXmlDecl();
    Source tmp = source;
    source = null;
    EnvelopeImpl envelope =
        (EnvelopeImpl) EnvelopeFactory.createEnvelope(tmp, this);

    if (!envelope.getNamespaceURI().equals(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
        log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
        throw new SOAPException("InputStream does not represent a valid SOAP 1.1 Message");
    }

    if (parser != null && !omitXmlDecl) {
        envelope.setOmitXmlDecl("no");
        envelope.setXmlDecl(parser.getXmlDeclaration());
        envelope.setCharsetEncoding(parser.getEncoding());
    }
    return envelope;
}
 
Example #26
Source File: LazyEnvelopeStaxReader.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public LazyEnvelopeStaxReader(EnvelopeImpl env) throws SOAPException, XMLStreamException {
        super(env);
//        this.env = env;
        bodyQName = new QName(env.getNamespaceURI(), "Body");
        payloadReader = env.getStaxBridge().getPayloadReader();
        int eventType = getEventType();
        while (eventType != START_ELEMENT) {
            eventType = nextTag();
        }
    }