jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/EnvelopeImpl.java
author aefimov
Thu, 16 Feb 2017 13:14:39 +0300
changeset 43852 93a527059d8a
parent 33547 e4c76ac38b12
child 45678 65fdff10664d
permissions -rw-r--r--
8174735: Update JAX-WS RI integration to latest version Reviewed-by: alanb, mchung, lancea Contributed-by: roman.grigoriadi@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
/*
43852
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
     2
 * Copyright (c) 1997, 2017, 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.impl;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    27
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    28
import java.io.IOException;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    29
import java.io.OutputStream;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    30
import java.io.OutputStreamWriter;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    31
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    32
import java.util.logging.Level;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    33
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    34
import javax.xml.namespace.QName;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    35
import javax.xml.soap.*;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    36
import javax.xml.stream.XMLStreamException;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    37
import javax.xml.stream.XMLStreamReader;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    38
import javax.xml.stream.XMLStreamWriter;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    39
import javax.xml.transform.*;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    40
import javax.xml.transform.dom.DOMSource;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    41
import javax.xml.transform.stream.StreamResult;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    42
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    43
import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    44
import com.sun.xml.internal.messaging.saaj.soap.LazyEnvelope;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    45
import com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    46
import com.sun.xml.internal.messaging.saaj.soap.StaxBridge;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    47
import com.sun.xml.internal.messaging.saaj.soap.StaxLazySourceBridge;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    48
import com.sun.xml.internal.messaging.saaj.soap.name.NameImpl;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    49
import com.sun.xml.internal.messaging.saaj.util.FastInfosetReflection;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    50
import com.sun.xml.internal.messaging.saaj.util.stax.LazyEnvelopeStaxReader;
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    51
import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    52
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    53
import com.sun.xml.internal.org.jvnet.staxex.util.DOMStreamReader;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    54
import com.sun.xml.internal.org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter;
43852
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
    55
import org.w3c.dom.Element;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    56
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    57
/**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    58
 * Our implementation of the SOAP envelope.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    59
 *
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    60
 * @author Anil Vijendran (anil@sun.com)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    61
 */
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
    62
public abstract class EnvelopeImpl extends ElementImpl implements LazyEnvelope {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    63
    protected HeaderImpl header;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    64
    protected BodyImpl body;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    65
    String omitXmlDecl = "yes";
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    66
    String charset = "utf-8";
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    67
    String xmlDecl = null;
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
    protected EnvelopeImpl(SOAPDocumentImpl ownerDoc, Name name) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    70
        super(ownerDoc, name);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    71
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    72
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    73
    protected EnvelopeImpl(SOAPDocumentImpl ownerDoc, QName name) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    74
        super(ownerDoc, name);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    75
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    76
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    77
    protected EnvelopeImpl(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    78
        SOAPDocumentImpl ownerDoc,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    79
        NameImpl name,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    80
        boolean createHeader,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    81
        boolean createBody)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    82
        throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    83
        this(ownerDoc, name);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    84
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    85
        ensureNamespaceIsDeclared(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    86
            getElementQName().getPrefix(), getElementQName().getNamespaceURI());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    87
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    88
        // XXX
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    89
        if (createHeader)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    90
            addHeader();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    91
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    92
        if (createBody)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    93
            addBody();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    94
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
    95
43852
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
    96
    public EnvelopeImpl(SOAPDocumentImpl ownerDoc, Element domElement) {
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
    97
        super(ownerDoc, domElement);
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
    98
    }
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
    99
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   100
    protected abstract NameImpl getHeaderName(String prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   101
    protected abstract NameImpl getBodyName(String prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   102
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   103
    public SOAPHeader addHeader() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   104
        return addHeader(null);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   105
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   106
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   107
    public SOAPHeader addHeader(String prefix) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   108
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   109
        if (prefix == null || prefix.equals("")) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   110
            prefix = getPrefix();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   111
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   112
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   113
        NameImpl headerName = getHeaderName(prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   114
        NameImpl bodyName = getBodyName(prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   115
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   116
        HeaderImpl header = null;
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   117
        SOAPElement firstChild = (SOAPElement) getFirstChildElement();
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   118
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   119
        if (firstChild != null) {
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   120
            if (firstChild.getElementName().equals(headerName)) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   121
                log.severe("SAAJ0120.impl.header.already.exists");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   122
                throw new SOAPExceptionImpl("Can't add a header when one is already present.");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   123
            } else if (!firstChild.getElementName().equals(bodyName)) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   124
                log.severe("SAAJ0121.impl.invalid.first.child.of.envelope");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   125
                throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   126
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   127
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   128
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   129
        header = (HeaderImpl) createElement(headerName);
43852
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
   130
        insertBefore(header.getDomElement(), firstChild);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   131
        header.ensureNamespaceIsDeclared(headerName.getPrefix(), headerName.getURI());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   132
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   133
        return header;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   134
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   135
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   136
    protected void lookForHeader() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   137
        NameImpl headerName = getHeaderName(null);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   138
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   139
        HeaderImpl hdr = (HeaderImpl) findChild(headerName);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   140
        header = hdr;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   141
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   142
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   143
    public SOAPHeader getHeader() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   144
        lookForHeader();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   145
        return header;
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
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   148
    protected void lookForBody() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   149
        NameImpl bodyName = getBodyName(null);
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
        BodyImpl bodyChildElement = (BodyImpl) findChild(bodyName);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   152
        body = bodyChildElement;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   153
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   154
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   155
    public SOAPBody addBody() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   156
        return addBody(null);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   157
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   158
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   159
    public SOAPBody addBody(String prefix) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   160
        lookForBody();
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
        if (prefix == null || prefix.equals("")) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   163
            prefix = getPrefix();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   164
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   165
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   166
        if (body == null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   167
            NameImpl bodyName = getBodyName(prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   168
            body = (BodyImpl) createElement(bodyName);
43852
93a527059d8a 8174735: Update JAX-WS RI integration to latest version
aefimov
parents: 33547
diff changeset
   169
            insertBefore(body.getDomElement(), null);
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   170
            body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   171
        } else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   172
            log.severe("SAAJ0122.impl.body.already.exists");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   173
            throw new SOAPExceptionImpl("Can't add a body when one is already present.");
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
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   176
        return body;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   177
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   178
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   179
    protected SOAPElement addElement(Name name) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   180
        if (getBodyName(null).equals(name)) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   181
            return addBody(name.getPrefix());
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
        if (getHeaderName(null).equals(name)) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   184
            return addHeader(name.getPrefix());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   185
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   186
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   187
        return super.addElement(name);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   188
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   189
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   190
    protected SOAPElement addElement(QName name) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   191
        if (getBodyName(null).equals(NameImpl.convertToName(name))) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   192
            return addBody(name.getPrefix());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   193
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   194
        if (getHeaderName(null).equals(NameImpl.convertToName(name))) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   195
            return addHeader(name.getPrefix());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   196
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   197
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   198
        return super.addElement(name);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   199
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   200
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   201
    public SOAPBody getBody() throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   202
        lookForBody();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   203
        return body;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   204
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   205
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   206
    public Source getContent() {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   207
        return new DOMSource(getOwnerDocument());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   208
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   209
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   210
    public Name createName(String localName, String prefix, String uri)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   211
        throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   212
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   213
        // validating parameters before passing them on
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   214
        // to make sure that the namespace specification rules are followed
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   215
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   216
        // reserved xmlns prefix cannot be used.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   217
        if ("xmlns".equals(prefix)) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   218
            log.severe("SAAJ0123.impl.no.reserved.xmlns");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   219
            throw new SOAPExceptionImpl("Cannot declare reserved xmlns prefix");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   220
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   221
        // Qualified name cannot be xmlns.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   222
        if ((prefix == null) && ("xmlns".equals(localName))) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   223
            log.severe("SAAJ0124.impl.qualified.name.cannot.be.xmlns");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   224
            throw new SOAPExceptionImpl("Qualified name cannot be xmlns");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   225
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   226
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   227
        return NameImpl.create(localName, prefix, uri);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   228
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   229
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   230
    public Name createName(String localName, String prefix)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   231
        throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   232
        String namespace = getNamespaceURI(prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   233
        if (namespace == null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   234
            log.log(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   235
                Level.SEVERE,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   236
                "SAAJ0126.impl.cannot.locate.ns",
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   237
                new String[] { prefix });
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   238
            throw new SOAPExceptionImpl(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   239
                "Unable to locate namespace for prefix " + prefix);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   240
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   241
        return NameImpl.create(localName, prefix, namespace);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   242
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   243
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   244
    public Name createName(String localName) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   245
        return NameImpl.createFromUnqualifiedName(localName);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   246
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   247
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   248
    public void setOmitXmlDecl(String value) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   249
        this.omitXmlDecl = value;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   250
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   251
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   252
    public void setXmlDecl(String value) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   253
        this.xmlDecl = value;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   254
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   255
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   256
    public void setCharsetEncoding(String value) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   257
        charset = value;
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   258
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   259
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   260
    public void output(OutputStream out) throws IOException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   261
        try {
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   262
//            materializeBody();
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   263
            Transformer transformer =
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   264
                EfficientStreamingTransformer.newTransformer();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   265
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   266
            transformer.setOutputProperty(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   267
                OutputKeys.OMIT_XML_DECLARATION, "yes");
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   268
                /*omitXmlDecl);*/
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   269
            // no equivalent for "setExpandEmptyElements"
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   270
            transformer.setOutputProperty(
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   271
                OutputKeys.ENCODING,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   272
                charset);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   273
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   274
            if (omitXmlDecl.equals("no") && xmlDecl == null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   275
                xmlDecl = "<?xml version=\"" + getOwnerDocument().getXmlVersion() + "\" encoding=\"" +
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   276
                    charset + "\" ?>";
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   277
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   278
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   279
           StreamResult result = new StreamResult(out);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   280
            if (xmlDecl != null) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   281
                OutputStreamWriter writer = new OutputStreamWriter(out, charset);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   282
                writer.write(xmlDecl);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   283
                writer.flush();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   284
                result = new StreamResult(writer);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   285
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   286
16791
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   287
            if (log.isLoggable(Level.FINE)) {
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   288
                log.log(Level.FINE, "SAAJ0190.impl.set.xml.declaration",
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   289
                        new String[] { omitXmlDecl });
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   290
                log.log(Level.FINE, "SAAJ0191.impl.set.encoding",
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   291
                        new String[] { charset });
fe5141eabb0e 8010393: Update JAX-WS RI to 2.2.9-b12941
alanb
parents: 12009
diff changeset
   292
            }
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   293
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   294
            //StreamResult result = new StreamResult(out);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   295
            transformer.transform(getContent(), result);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   296
        } catch (Exception ex) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   297
            throw new IOException(ex.getMessage());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   298
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   299
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   300
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   301
    /**
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   302
     * Serialize to FI if boolean parameter set.
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   303
     */
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   304
    public void output(OutputStream out, boolean isFastInfoset)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   305
        throws IOException
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   306
    {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   307
        if (!isFastInfoset) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   308
            output(out);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   309
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   310
        else {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   311
            try {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   312
                // Run transform and generate FI output from content
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   313
                Transformer transformer = EfficientStreamingTransformer.newTransformer();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   314
                    transformer.transform(getContent(),
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   315
                        FastInfosetReflection.FastInfosetResult_new(out));
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   316
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   317
            catch (Exception ex) {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   318
                throw new IOException(ex.getMessage());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   319
            }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   320
        }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   321
    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   322
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   323
    //    public void prettyPrint(OutputStream out) throws IOException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   324
    //        if (getDocument() == null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   325
    //            initDocument();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   326
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   327
    //        OutputFormat format = OutputFormat.createPrettyPrint();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   328
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   329
    //        format.setIndentSize(2);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   330
    //        format.setNewlines(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   331
    //        format.setTrimText(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   332
    //        format.setPadText(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   333
    //        format.setExpandEmptyElements(false);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   334
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   335
    //        XMLWriter writer = new XMLWriter(out, format);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   336
    //        writer.write(getDocument());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   337
    //    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   338
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   339
    //    public void prettyPrint(Writer out) throws IOException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   340
    //        if (getDocument() == null)
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   341
    //            initDocument();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   342
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   343
    //        OutputFormat format = OutputFormat.createPrettyPrint();
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   344
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   345
    //        format.setIndentSize(2);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   346
    //        format.setNewlines(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   347
    //        format.setTrimText(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   348
    //        format.setPadText(true);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   349
    //        format.setExpandEmptyElements(false);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   350
    //
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   351
    //        XMLWriter writer = new XMLWriter(out, format);
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   352
    //        writer.write(getDocument());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   353
    //    }
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   354
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   355
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   356
     public SOAPElement setElementQName(QName newName) throws SOAPException {
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   357
        log.log(Level.SEVERE,
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   358
                "SAAJ0146.impl.invalid.name.change.requested",
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   359
                new Object[] {elementQName.getLocalPart(),
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   360
                              newName.getLocalPart()});
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   361
        throw new SOAPException("Cannot change name for "
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   362
                                + elementQName.getLocalPart() + " to "
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   363
                                + newName.getLocalPart());
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   364
     }
23782
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   365
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   366
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   367
    public void setStaxBridge(StaxBridge bridge) throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   368
        //set it on the body
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   369
        ((BodyImpl) getBody()).setStaxBridge(bridge);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   370
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   371
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   372
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   373
    public StaxBridge getStaxBridge() throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   374
        return ((BodyImpl) getBody()).getStaxBridge();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   375
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   376
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   377
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   378
    public XMLStreamReader getPayloadReader() throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   379
        return ((BodyImpl) getBody()).getPayloadReader();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   380
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   381
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   382
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   383
    public void writeTo(final XMLStreamWriter writer) throws XMLStreamException, SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   384
        StaxBridge readBridge = this.getStaxBridge();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   385
        if (readBridge != null && readBridge instanceof StaxLazySourceBridge) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   386
//              StaxSoapWriteBridge writingBridge =  new StaxSoapWriteBridge(this);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   387
//              writingBridge.write(writer);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   388
                final String soapEnvNS = this.getNamespaceURI();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   389
                final DOMStreamReader reader = new DOMStreamReader(this);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   390
                XMLStreamReaderToXMLStreamWriter writingBridge =  new XMLStreamReaderToXMLStreamWriter();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   391
                writingBridge.bridge( new XMLStreamReaderToXMLStreamWriter.Breakpoint(reader, writer) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   392
                        public boolean proceedAfterStartElement()  {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   393
                                if ("Body".equals(reader.getLocalName()) && soapEnvNS.equals(reader.getNamespaceURI()) ){
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   394
                                        return false;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   395
                                } else
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   396
                                        return true;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   397
                        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   398
            });//bridgeToBodyStartTag
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   399
            ((StaxLazySourceBridge)readBridge).writePayloadTo(writer);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   400
            writer.writeEndElement();//body
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   401
            writer.writeEndElement();//env
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   402
            writer.writeEndDocument();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   403
            writer.flush();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   404
        } else {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   405
                LazyEnvelopeStaxReader lazyEnvReader = new LazyEnvelopeStaxReader(this);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   406
                XMLStreamReaderToXMLStreamWriter writingBridge = new XMLStreamReaderToXMLStreamWriter();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   407
                writingBridge.bridge(lazyEnvReader, writer);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   408
//            writingBridge.bridge(new XMLStreamReaderToXMLStreamWriter.Breakpoint(lazyEnvReader, writer));
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   409
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   410
        //Assume the staxBridge is exhausted now since we would have read the body reader
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   411
        ((BodyImpl) getBody()).setPayloadStreamRead();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   412
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   413
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   414
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   415
    public QName getPayloadQName() throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   416
        return ((BodyImpl) getBody()).getPayloadQName();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   417
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   418
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   419
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   420
    public String getPayloadAttributeValue(String localName) throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   421
        return ((BodyImpl) getBody()).getPayloadAttributeValue(localName);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   422
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   423
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   424
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   425
    public String getPayloadAttributeValue(QName qName) throws SOAPException {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   426
        return ((BodyImpl) getBody()).getPayloadAttributeValue(qName);
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   427
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   428
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   429
    @Override
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   430
    public boolean isLazy() {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   431
        try {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   432
            return ((BodyImpl) getBody()).isLazy();
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   433
        } catch (SOAPException e) {
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   434
            return false;
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   435
        }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   436
    }
953bfc3fbe31 8036030: Update JAX-WS RI integration to latest version
mkos
parents: 22679
diff changeset
   437
12009
4abb694f273a 7150322: Stop using drop source bundles in jaxws
ohair
parents:
diff changeset
   438
}