jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/soap/impl/BodyImpl.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 |
34 import javax.xml.stream.XMLStreamException; |
34 import javax.xml.stream.XMLStreamException; |
35 import javax.xml.stream.XMLStreamReader; |
35 import javax.xml.stream.XMLStreamReader; |
36 import javax.xml.parsers.DocumentBuilder; |
36 import javax.xml.parsers.DocumentBuilder; |
37 import javax.xml.parsers.DocumentBuilderFactory; |
37 import javax.xml.parsers.DocumentBuilderFactory; |
38 |
38 |
|
39 import com.sun.xml.internal.messaging.saaj.util.SAAJUtil; |
39 import org.w3c.dom.*; |
40 import org.w3c.dom.*; |
40 import org.w3c.dom.Node; |
41 import org.w3c.dom.Node; |
41 |
42 |
42 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; |
43 import com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl; |
43 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument; |
44 import com.sun.xml.internal.messaging.saaj.soap.SOAPDocument; |
58 |
59 |
59 protected BodyImpl(SOAPDocumentImpl ownerDoc, NameImpl bodyName) { |
60 protected BodyImpl(SOAPDocumentImpl ownerDoc, NameImpl bodyName) { |
60 super(ownerDoc, bodyName); |
61 super(ownerDoc, bodyName); |
61 } |
62 } |
62 |
63 |
|
64 public BodyImpl(SOAPDocumentImpl ownerDoc, Element domElement) { |
|
65 super(ownerDoc, domElement); |
|
66 } |
|
67 |
63 protected abstract NameImpl getFaultName(String name); |
68 protected abstract NameImpl getFaultName(String name); |
64 protected abstract boolean isFault(SOAPElement child); |
69 protected abstract boolean isFault(SOAPElement child); |
65 protected abstract SOAPBodyElement createBodyElement(Name name); |
70 protected abstract SOAPBodyElement createBodyElement(Name name); |
66 protected abstract SOAPBodyElement createBodyElement(QName name); |
71 protected abstract SOAPBodyElement createBodyElement(QName name); |
67 protected abstract SOAPFault createFaultElement(); |
72 protected abstract SOAPFault createFaultElement(); |
153 |
158 |
154 public SOAPFault getFault() { |
159 public SOAPFault getFault() { |
155 if (hasFault()) { |
160 if (hasFault()) { |
156 if (fault == null) { |
161 if (fault == null) { |
157 //initialize fault member |
162 //initialize fault member |
158 fault = (SOAPFault) getFirstChildElement(); |
163 fault = (SOAPFault) getSoapDocument().find(getFirstChildElement()); |
159 } |
164 } |
160 return fault; |
165 return fault; |
161 } |
166 } |
162 return null; |
167 return null; |
163 } |
168 } |
257 return newBodyElement; |
262 return newBodyElement; |
258 //*/ |
263 //*/ |
259 } |
264 } |
260 |
265 |
261 protected SOAPElement convertToSoapElement(Element element) { |
266 protected SOAPElement convertToSoapElement(Element element) { |
262 if ((element instanceof SOAPBodyElement) && |
267 final Node soapNode = getSoapDocument().findIfPresent(element); |
|
268 if ((soapNode instanceof SOAPBodyElement) && |
263 //this check is required because ElementImpl currently |
269 //this check is required because ElementImpl currently |
264 // implements SOAPBodyElement |
270 // implements SOAPBodyElement |
265 !(element.getClass().equals(ElementImpl.class))) { |
271 !(soapNode.getClass().equals(ElementImpl.class))) { |
266 return (SOAPElement) element; |
272 return (SOAPElement) soapNode; |
267 } else { |
273 } else { |
268 return replaceElementWithSOAPElement( |
274 return replaceElementWithSOAPElement( |
269 element, |
275 element, |
270 (ElementImpl) createBodyElement(NameImpl |
276 (ElementImpl) createBodyElement(NameImpl |
271 .copyElementName(element))); |
277 .copyElementName(element))); |
312 throw new SOAPException("Cannot extract Document from body"); |
318 throw new SOAPException("Cannot extract Document from body"); |
313 } |
319 } |
314 |
320 |
315 Document document = null; |
321 Document document = null; |
316 try { |
322 try { |
317 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); |
323 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance("com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl", SAAJUtil.getSystemClassLoader()); |
318 factory.setNamespaceAware(true); |
324 factory.setNamespaceAware(true); |
319 DocumentBuilder builder = factory.newDocumentBuilder(); |
325 DocumentBuilder builder = factory.newDocumentBuilder(); |
320 document = builder.newDocument(); |
326 document = builder.newDocument(); |
321 |
327 |
322 Element rootElement = (Element) document.importNode( |
328 Element rootElement = (Element) document.importNode( |
438 return staxBridge.getPayloadAttributeValue(attName); |
444 return staxBridge.getPayloadAttributeValue(attName); |
439 } else { |
445 } else { |
440 //not lazy -Just get first child element and return its attribute |
446 //not lazy -Just get first child element and return its attribute |
441 Element elem = getFirstChildElement(); |
447 Element elem = getFirstChildElement(); |
442 if (elem != null) { |
448 if (elem != null) { |
443 return elem.getAttribute(localName); |
449 return elem.getAttribute(getLocalName()); |
444 } |
450 } |
445 } |
451 } |
446 return null; |
452 return null; |
447 } |
453 } |
448 |
454 |