Search in sources :

Example 1 with SAAJMetaFactory

use of javax.xml.soap.SAAJMetaFactory in project tomee by apache.

the class SaajMetaFactoryImpl method callFactoryMethod.

private Object callFactoryMethod(String methodName, String arg) throws SOAPException {
    SAAJMetaFactory factory = (SAAJMetaFactory) SaajFactoryFinder.find("javax.xml.soap.MetaFactory");
    try {
        Method method = factory.getClass().getDeclaredMethod(methodName, new Class[] { String.class });
        boolean accessibility = method.isAccessible();
        try {
            method.setAccessible(true);
            Object result = method.invoke(factory, new Object[] { arg });
            return result;
        } catch (InvocationTargetException e) {
            if (e.getTargetException() instanceof SOAPException) {
                throw (SOAPException) e.getTargetException();
            } else {
                throw new SOAPException("Error calling factory method: " + methodName, e);
            }
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new SOAPException("Error calling factory method: " + methodName, e);
        } finally {
            method.setAccessible(accessibility);
        }
    } catch (NoSuchMethodException e) {
        throw new SOAPException("Factory method not found: " + methodName, e);
    }
}
Also used : SAAJMetaFactory(javax.xml.soap.SAAJMetaFactory) SOAPException(javax.xml.soap.SOAPException) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 SAAJMetaFactory (javax.xml.soap.SAAJMetaFactory)1 SOAPException (javax.xml.soap.SOAPException)1