jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/EnvelopeImpl.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
50 import com.sun.xml.internal.messaging.saaj.util.stax.LazyEnvelopeStaxReader; |
50 import com.sun.xml.internal.messaging.saaj.util.stax.LazyEnvelopeStaxReader; |
51 import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; |
51 import com.sun.xml.internal.messaging.saaj.util.transform.EfficientStreamingTransformer; |
52 |
52 |
53 import com.sun.xml.internal.org.jvnet.staxex.util.DOMStreamReader; |
53 import com.sun.xml.internal.org.jvnet.staxex.util.DOMStreamReader; |
54 import com.sun.xml.internal.org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter; |
54 import com.sun.xml.internal.org.jvnet.staxex.util.XMLStreamReaderToXMLStreamWriter; |
|
55 import org.w3c.dom.Element; |
55 |
56 |
56 /** |
57 /** |
57 * Our implementation of the SOAP envelope. |
58 * Our implementation of the SOAP envelope. |
58 * |
59 * |
59 * @author Anil Vijendran (anil@sun.com) |
60 * @author Anil Vijendran (anil@sun.com) |
90 |
91 |
91 if (createBody) |
92 if (createBody) |
92 addBody(); |
93 addBody(); |
93 } |
94 } |
94 |
95 |
|
96 public EnvelopeImpl(SOAPDocumentImpl ownerDoc, Element domElement) { |
|
97 super(ownerDoc, domElement); |
|
98 } |
|
99 |
95 protected abstract NameImpl getHeaderName(String prefix); |
100 protected abstract NameImpl getHeaderName(String prefix); |
96 protected abstract NameImpl getBodyName(String prefix); |
101 protected abstract NameImpl getBodyName(String prefix); |
97 |
102 |
98 public SOAPHeader addHeader() throws SOAPException { |
103 public SOAPHeader addHeader() throws SOAPException { |
99 return addHeader(null); |
104 return addHeader(null); |
120 throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body"); |
125 throw new SOAPExceptionImpl("First child of Envelope must be either a Header or Body"); |
121 } |
126 } |
122 } |
127 } |
123 |
128 |
124 header = (HeaderImpl) createElement(headerName); |
129 header = (HeaderImpl) createElement(headerName); |
125 insertBefore(header, firstChild); |
130 insertBefore(header.getDomElement(), firstChild); |
126 header.ensureNamespaceIsDeclared(headerName.getPrefix(), headerName.getURI()); |
131 header.ensureNamespaceIsDeclared(headerName.getPrefix(), headerName.getURI()); |
127 |
132 |
128 return header; |
133 return header; |
129 } |
134 } |
130 |
135 |
159 } |
164 } |
160 |
165 |
161 if (body == null) { |
166 if (body == null) { |
162 NameImpl bodyName = getBodyName(prefix); |
167 NameImpl bodyName = getBodyName(prefix); |
163 body = (BodyImpl) createElement(bodyName); |
168 body = (BodyImpl) createElement(bodyName); |
164 insertBefore(body, null); |
169 insertBefore(body.getDomElement(), null); |
165 body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI()); |
170 body.ensureNamespaceIsDeclared(bodyName.getPrefix(), bodyName.getURI()); |
166 } else { |
171 } else { |
167 log.severe("SAAJ0122.impl.body.already.exists"); |
172 log.severe("SAAJ0122.impl.body.already.exists"); |
168 throw new SOAPExceptionImpl("Can't add a body when one is already present."); |
173 throw new SOAPExceptionImpl("Can't add a body when one is already present."); |
169 } |
174 } |