Example usage for javax.xml.soap SOAPElement getClass

List of usage examples for javax.xml.soap SOAPElement getClass

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java

/**
 * Gets the SAAJ version for the specified {@link javax.xml.soap.SOAPElement}.
 *
 * @return a code comparable to the SAAJ_XX codes in this class
 * @see #SAAJ_11//from w w w .  j  a va 2s.  c  o  m
 * @see #SAAJ_12
 * @see #SAAJ_13
 */
public static int getSaajVersion(SOAPElement soapElement) {
    Assert.notNull(soapElement, "'soapElement' must not be null");
    String soapElementClassName = soapElement.getClass().getName();
    Integer saajVersion = saajVersions.get(soapElementClassName);
    if (saajVersion == null) {
        if (isSaaj12(soapElement)) {
            if (isSaaj13(soapElement)) {
                saajVersion = SAAJ_13;
            } else {
                saajVersion = SAAJ_12;
            }
        } else {
            saajVersion = SAAJ_11;
        }
        saajVersions.put(soapElementClassName, saajVersion);
        if (logger.isTraceEnabled()) {
            logger.trace("SOAPElement [" + soapElement.getClass().getName() + "] implements "
                    + getSaajVersionString(saajVersion));
        }
    }
    return saajVersion;
}

From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java

private static boolean isSaaj13(SOAPElement soapElement) {
    try {//from w  w w.ja  v a2s. c  o  m
        Method m = soapElement.getClass().getMethod("getElementQName", new Class[0]);
        // we might be using the SAAJ 1.3 API, while the impl is 1.2
        // let's see if the method is not abstract
        if (Modifier.isAbstract(m.getModifiers())) {
            logger.warn("Detected SAAJ API version 1.3, while implementation provides version 1.2. "
                    + "Please replace the SAAJ API jar with a version that corresponds to your runtime"
                    + " implementation (which might be provided by your app server).");
            return false;
        } else {
            return true;
        }
    } catch (NoSuchMethodException e) {
        // getElementQName not found
        return false;
    }
}

From source file:org.springframework.ws.soap.saaj.support.SaajUtils.java

/**
 * Checks whether we can find a SAAJ 1.2 implementation, being aware of the broken WebLogic 9 SAAJ implementation.
 * <p/>//from  w  w  w  .  j av a 2 s. com
 * WebLogic 9 does implement SAAJ 1.2, but throws UnsupportedOperationExceptions when a SAAJ 1.2 method is called.
 */
private static boolean isSaaj12(SOAPElement soapElement) {
    try {
        Method m = soapElement.getClass().getMethod("getPrefix", new Class[0]);
        // we might be using the SAAJ 1.2 API, while the impl is 1.1
        // let's see if the method is not abstract
        if (Modifier.isAbstract(m.getModifiers())) {
            logger.warn("Detected SAAJ API version 1.2, while implementation provides version 1.1. "
                    + "Please replace the SAAJ API jar with a version that corresponds to your runtime "
                    + "implementation (which might be provided by your app server).");
            return false;
        } else {
            soapElement.getPrefix();
            return true;
        }
    } catch (NoSuchMethodException e) {
        // getPrefix not found
        return false;
    } catch (UnsupportedOperationException ex) {
        // getPrefix results in UOE, let's see if we're dealing with WL 9
        if (WEBLOGIC_9_SAAJ_EXCEPTION_MESSAGE.equals(ex.getMessage())) {
            return false;
        } else {
            throw ex;
        }
    }
}