1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
/* * $Id: SAAJResult.java,v 1.3 2006/03/09 16:09:42 vj135062 Exp $ */ /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.xml.soap; import javax.xml.transform.dom.DOMResult; /** * Acts as a holder for the results of a JAXP transformation or a JAXB * marshalling, in the form of a SAAJ tree. These results should be accessed * by using the {@link #getResult()} method. The {@link DOMResult#getNode()} * method should be avoided in almost all cases. * * @author XWS-Security Development Team * * @since SAAJ 1.3 */ public class SAAJResult extends DOMResult { /** * Creates a <code>SAAJResult</code> that will present results in the form * of a SAAJ tree that supports the default (SOAP 1.1) protocol. * <p> * This kind of <code>SAAJResult</code> is meant for use in situations where the * results will be used as a parameter to a method that takes a parameter * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ * API. When used in a transformation, the results are populated into the * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created internally. * The <code>SOAPPart</code> returned by {@link DOMResult#getNode()} * is not guaranteed to be well-formed. * * @throws SOAPException if there is a problem creating a <code>SOAPMessage</code> * * @since SAAJ 1.3 */ public SAAJResult() throws SOAPException { this(MessageFactory.newInstance().createMessage()); } /** * Creates a <code>SAAJResult</code> that will present results in the form * of a SAAJ tree that supports the specified protocol. The * <code>DYNAMIC_SOAP_PROTOCOL</code> is ambiguous in this context and will * cause this constructor to throw an <code>UnsupportedOperationException</code>. * <p> * This kind of <code>SAAJResult</code> is meant for use in situations where the * results will be used as a parameter to a method that takes a parameter * whose type, such as <code>SOAPElement</code>, is drawn from the SAAJ * API. When used in a transformation the results are populated into the * <code>SOAPPart</code> of a <code>SOAPMessage</code> that is created * internally. The <code>SOAPPart</code> returned by {@link DOMResult#getNode()} * is not guaranteed to be well-formed. * * @param protocol - the name of the SOAP protocol that the resulting SAAJ * tree should support * * @throws SOAPException if a <code>SOAPMessage</code> supporting the * specified protocol cannot be created * * @since SAAJ 1.3 */ public SAAJResult(String protocol) throws SOAPException { this(MessageFactory.newInstance(protocol).createMessage()); } /** * Creates a <code>SAAJResult</code> that will write the results into the * <code>SOAPPart</code> of the supplied <code>SOAPMessage</code>. * In the normal case these results will be written using DOM APIs and, * as a result, the finished <code>SOAPPart</code> will not be guaranteed * to be well-formed unless the data used to create it is also well formed. * When used in a transformation the validity of the <code>SOAPMessage</code> * after the transformation can be guaranteed only by means outside SAAJ * specification. * * @param message - the message whose <code>SOAPPart</code> will be * populated as a result of some transformation or * marshalling operation * * @since SAAJ 1.3 */ public SAAJResult(SOAPMessage message) { super(message.getSOAPPart()); } /** * Creates a <code>SAAJResult</code> that will write the results as a * child node of the <code>SOAPElement</code> specified. In the normal * case these results will be written using DOM APIs and as a result may * invalidate the structure of the SAAJ tree. This kind of * <code>SAAJResult</code> should only be used when the validity of the * incoming data can be guaranteed by means outside of the SAAJ * specification. * * @param rootNode - the root to which the results will be appended * * @since SAAJ 1.3 */ public SAAJResult(SOAPElement rootNode) { super(rootNode); } /** * @return the resulting Tree that was created under the specified root Node. * @since SAAJ 1.3 */ public javax.xml.soap.Node getResult() { return (javax.xml.soap.Node)super.getNode().getFirstChild(); } }