01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package javax.xml.soap;
21:
22: import org.w3c.dom.NodeList;
23:
24: import javax.xml.transform.dom.DOMResult;
25:
26: public class SAAJResult extends DOMResult {
27:
28: public SAAJResult() throws SOAPException {
29: this (MessageFactory.newInstance().createMessage());
30: org.w3c.dom.Node node = this .getNode();
31: NodeList nodeList = node.getChildNodes();
32: if (nodeList != null) {
33: int size = nodeList.getLength();
34: for (int a = 0; a < size; a++) {
35: node.removeChild(nodeList.item(a));
36: }
37: }
38: this .setNode(null);
39: }
40:
41: public SAAJResult(String s) throws SOAPException {
42: this (MessageFactory.newInstance(s).createMessage());
43: }
44:
45: public SAAJResult(SOAPMessage soapmessage) {
46: super (soapmessage.getSOAPPart());
47: }
48:
49: public SAAJResult(SOAPElement soapelement) {
50: super (soapelement);
51: }
52:
53: public javax.xml.soap.Node getResult() {
54: org.w3c.dom.Node node = super .getNode();
55: //When using SAAJResult saajResult = new SAAJResult();
56: if (node == null) {
57: return null;
58: }
59: if (node instanceof SOAPPart) {
60: try {
61: return ((SOAPPart) node).getEnvelope();
62: } catch (SOAPException e) {
63: throw new RuntimeException(e);
64: }
65: }
66: return (javax.xml.soap.Node) node.getFirstChild();
67: }
68: }
|