jaxws/src/java.xml.soap/share/classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java
author chegar
Sun, 17 Aug 2014 15:52:15 +0100
changeset 25871 b80b84e87032
parent 25429 jaxws/src/share/jaxws_classes/com/sun/xml/internal/messaging/saaj/soap/EnvelopeFactory.java@1c4e76ec718a
permissions -rw-r--r--
8054834: Modular Source Code Reviewed-by: alanb, chegar, ihse, mduigou Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, magnus.ihse.bursie@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, paul.sandoz@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     1
/*
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     4
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    10
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    15
 * accompanied this code).
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    16
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    20
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    23
 * questions.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    24
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    25
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    26
package com.sun.xml.internal.messaging.saaj.soap;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    27
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    28
import com.sun.xml.internal.messaging.saaj.LazyEnvelopeSource;
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    29
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    30
import com.sun.xml.internal.messaging.saaj.util.JAXMStreamSource;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    31
import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    32
import com.sun.xml.internal.messaging.saaj.util.ParserPool;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    33
import com.sun.xml.internal.messaging.saaj.util.RejectDoctypeSaxFilter;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    34
import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    35
import org.xml.sax.InputSource;
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    36
import org.xml.sax.XMLReader;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    37
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    38
import javax.xml.parsers.SAXParser;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    39
import javax.xml.soap.SOAPException;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    40
import javax.xml.stream.XMLInputFactory;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    41
import javax.xml.stream.XMLStreamException;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    42
import javax.xml.stream.XMLStreamReader;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    43
import javax.xml.transform.Source;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    44
import javax.xml.transform.Transformer;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    45
import javax.xml.transform.dom.DOMResult;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    46
import javax.xml.transform.sax.SAXSource;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    47
import javax.xml.transform.stax.StAXSource;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    48
import javax.xml.transform.stream.StreamSource;
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    49
import java.util.logging.Logger;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    50
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    51
/**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    52
 * EnvelopeFactory creates SOAP Envelope objects using different
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    53
 * underlying implementations.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    54
 */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    55
public class EnvelopeFactory {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    56
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    57
    protected static final Logger
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    58
        log = Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    59
        "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    60
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    61
    private static ContextClassloaderLocal<ParserPool> parserPool =
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    62
            new ContextClassloaderLocal<ParserPool>() {
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    63
                @Override
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    64
                protected ParserPool initialValue() throws Exception {
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    65
                    return new ParserPool(5);
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    66
                }
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
    67
            };
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    68
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    69
    public static Envelope createEnvelope(Source src, SOAPPartImpl soapPart)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    70
        throws SOAPException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    71
    {
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    72
            if (src instanceof JAXMStreamSource) {
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    73
                try {
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    74
                    if (!SOAPPartImpl.lazyContentLength) {
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    75
                        ((JAXMStreamSource) src).reset();
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    76
                    }
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    77
                } catch (java.io.IOException ioe) {
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    78
                    log.severe("SAAJ0515.source.reset.exception");
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    79
                    throw new SOAPExceptionImpl(ioe);
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    80
                }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    81
            }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    82
        if (src instanceof LazyEnvelopeSource) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    83
          return lazy((LazyEnvelopeSource)src, soapPart);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    84
      }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    85
        if (soapPart.message.isLazySoapBodyParsing()) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    86
            return parseEnvelopeStax(src, soapPart);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    87
        } else {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    88
            return parseEnvelopeSax(src, soapPart);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    89
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    90
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    91
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    92
    private static Envelope lazy(LazyEnvelopeSource src, SOAPPartImpl soapPart) throws SOAPException {
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
    93
            try {
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    94
                StaxBridge staxBridge = new StaxLazySourceBridge(src, soapPart);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    95
                staxBridge.bridgeEnvelopeAndHeaders();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    96
            Envelope env = (Envelope) soapPart.getEnvelope();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    97
            env.setStaxBridge(staxBridge);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    98
            return env;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    99
        } catch (XMLStreamException e) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   100
            throw new SOAPException(e);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   101
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   102
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   103
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   104
    static private XMLInputFactory xmlInputFactory = null;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   105
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   106
    private static Envelope parseEnvelopeStax(Source src, SOAPPartImpl soapPart)
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   107
            throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   108
        XMLStreamReader streamReader = null;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   109
        if (src instanceof StAXSource) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   110
           streamReader = ((StAXSource) src).getXMLStreamReader();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   111
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   112
        try {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   113
            if (streamReader == null) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   114
                if (xmlInputFactory == null) xmlInputFactory = XMLInputFactory.newInstance();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   115
                streamReader = xmlInputFactory.createXMLStreamReader(src);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   116
            }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   117
//            SaajStaxWriter saajWriter = new SaajStaxWriter(soapPart.message, soapPart.document);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   118
//            XMLStreamReaderToXMLStreamWriter readerWriterBridge = new XMLStreamReaderToXMLStreamWriter(
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   119
//                    streamReader, saajWriter, soapPart.getSOAPNamespace());
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   120
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   121
            StaxBridge readerWriterBridge = new StaxReaderBridge(streamReader, soapPart);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   122
            //bridge will stop reading at body element, and parse upon request, so save it
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   123
            //on the envelope
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   124
            readerWriterBridge.bridgeEnvelopeAndHeaders();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   125
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   126
            Envelope env = (Envelope) soapPart.getEnvelope();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   127
            env.setStaxBridge(readerWriterBridge);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   128
            return env;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   129
        } catch (Exception e) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   130
            throw new SOAPException(e);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   131
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   132
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   133
    private static Envelope parseEnvelopeSax(Source src, SOAPPartImpl soapPart)
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   134
            throws SOAPException {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   135
        // Insert SAX filter to disallow Document Type Declarations since
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   136
        // they are not legal in SOAP
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   137
        SAXParser saxParser = null;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   138
        if (src instanceof StreamSource) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   139
            try {
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
   140
                saxParser = parserPool.get().get();
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   141
            } catch (Exception e) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   142
                log.severe("SAAJ0601.util.newSAXParser.exception");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   143
                throw new SOAPExceptionImpl(
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   144
                    "Couldn't get a SAX parser while constructing a envelope",
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   145
                    e);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   146
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   147
            InputSource is = SAXSource.sourceToInputSource(src);
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   148
            if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   149
                is.setEncoding(soapPart.getSourceCharsetEncoding());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   150
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   151
            XMLReader rejectFilter;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   152
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   153
                rejectFilter = new RejectDoctypeSaxFilter(saxParser);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   154
            } catch (Exception ex) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   155
                log.severe("SAAJ0510.soap.cannot.create.envelope");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   156
                throw new SOAPExceptionImpl(
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   157
                    "Unable to create envelope from given source: ",
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   158
                    ex);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   159
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   160
            src = new SAXSource(rejectFilter, is);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   161
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   162
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   163
        try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   164
            Transformer transformer =
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   165
                EfficientStreamingTransformer.newTransformer();
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   166
            DOMResult result = new DOMResult(soapPart);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   167
            transformer.transform(src, result);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   168
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   169
            Envelope env = (Envelope) soapPart.getEnvelope();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   170
            return env;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   171
        } catch (Exception ex) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   172
            if (ex instanceof SOAPVersionMismatchException) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   173
                throw (SOAPVersionMismatchException) ex;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   174
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   175
            log.severe("SAAJ0511.soap.cannot.create.envelope");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   176
            throw new SOAPExceptionImpl(
25429
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   177
                "Unable to create envelope from given source: ",
1c4e76ec718a 8044656: Update JAX-WS RI integration to latest version
mkos
parents: 23961
diff changeset
   178
                ex);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   179
        } finally {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   180
            if (saxParser != null) {
23961
439846965790 8026188: Enhance envelope factory
mkos
parents: 23782
diff changeset
   181
                parserPool.get().returnParser(saxParser);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   182
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   183
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   184
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   185
}