Search in sources :

Example 1 with SOAPCloneOptions

use of org.apache.axiom.soap.SOAPCloneOptions in project webservices-axiom by apache.

the class TestClone method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeader header = soapFactory.createSOAPHeader();
    OMNamespace ns = soapFactory.createOMNamespace("urn:test", "p");
    SOAPHeaderBlock unprocessedHeaderBlock = header.addHeaderBlock("unprocessed", ns);
    SOAPHeaderBlock processedHeaderBlock = header.addHeaderBlock("processed", ns);
    processedHeaderBlock.setProcessed();
    SOAPCloneOptions options = new SOAPCloneOptions();
    options.setPreserveModel(true);
    options.setProcessedFlag(processed);
    SOAPHeader clonedHeader = (SOAPHeader) header.clone(options);
    checkProcessed(clonedHeader, unprocessedHeaderBlock);
    checkProcessed(clonedHeader, processedHeaderBlock);
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) SOAPHeader(org.apache.axiom.soap.SOAPHeader) SOAPCloneOptions(org.apache.axiom.soap.SOAPCloneOptions)

Example 2 with SOAPCloneOptions

use of org.apache.axiom.soap.SOAPCloneOptions in project webservices-axiom by apache.

the class TestCloneProcessedWithoutPreservingModel method runTest.

@Override
protected void runTest() throws Throwable {
    SOAPHeaderBlock headerBlock = soapFactory.createSOAPHeaderBlock("test", soapFactory.createOMNamespace("urn:test", "p"));
    headerBlock.setProcessed();
    OMElement clone = (OMElement) headerBlock.clone(new SOAPCloneOptions());
    assertThat(clone).isNotInstanceOf(SOAPHeaderBlock.class);
}
Also used : SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) OMElement(org.apache.axiom.om.OMElement) SOAPCloneOptions(org.apache.axiom.soap.SOAPCloneOptions)

Example 3 with SOAPCloneOptions

use of org.apache.axiom.soap.SOAPCloneOptions in project webservices-axiom by apache.

the class CopyUtils method copy.

/**
 * @deprecated This method has the same effect as calling
 *             {@link OMInformationItem#clone(OMCloneOptions)} on the source
 *             {@link SOAPEnvelope} with the following options enabled:
 *             <ul>
 *             <li>{@link OMCloneOptions#setFetchDataHandlers(boolean)}
 *             <li>{@link OMCloneOptions#setPreserveModel(boolean)}
 *             <li>{@link OMCloneOptions#setCopyOMDataSources(boolean)}
 *             </ul>
 *             Instead of using this method, application code should use
 *             {@link OMInformationItem#clone(OMCloneOptions)} directly and fine tune the
 *             options for the particular use case.
 */
public static SOAPEnvelope copy(SOAPEnvelope sourceEnv) {
    SOAPCloneOptions options = new SOAPCloneOptions();
    options.setFetchDataHandlers(true);
    options.setPreserveModel(true);
    options.setCopyOMDataSources(true);
    return (SOAPEnvelope) sourceEnv.clone(options);
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPCloneOptions(org.apache.axiom.soap.SOAPCloneOptions)

Example 4 with SOAPCloneOptions

use of org.apache.axiom.soap.SOAPCloneOptions in project webservices-axiom by apache.

the class CloneTestCase method copyAndCheck.

/**
 * Make a copy of the source envelope and validate the target tree
 * @param sourceEnv
 * @throws Exception
 */
protected void copyAndCheck(SOAPEnvelope sourceEnv) throws Exception {
    SOAPCloneOptions options = new SOAPCloneOptions();
    options.setFetchDataHandlers(true);
    options.setPreserveModel(true);
    options.setCopyOMDataSources(true);
    SOAPEnvelope targetEnv = (SOAPEnvelope) sourceEnv.clone(options);
    identityCheck(sourceEnv, targetEnv, "");
    assertAbout(xml()).that(targetEnv.toString()).hasSameContentAs(sourceEnv.toString());
    sourceEnv.close(false);
}
Also used : SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) SOAPCloneOptions(org.apache.axiom.soap.SOAPCloneOptions)

Aggregations

SOAPCloneOptions (org.apache.axiom.soap.SOAPCloneOptions)4 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)2 SOAPHeaderBlock (org.apache.axiom.soap.SOAPHeaderBlock)2 OMElement (org.apache.axiom.om.OMElement)1 OMNamespace (org.apache.axiom.om.OMNamespace)1 SOAPHeader (org.apache.axiom.soap.SOAPHeader)1