Search in sources :

Example 1 with AxisCompatible

use of com.google.api.ads.common.lib.soap.compatability.AxisCompatible in project googleads-java-lib by googleads.

the class AxisHandler method createSoapClient.

/**
 * Creates a SOAP client using a SOAP service descriptor.
 *
 * @param soapServiceDescriptor the descriptor to use for creating a client
 * @return the SOAP client for this descriptor
 * @throws ServiceException thrown if the SOAP client cannot be created
 */
@Override
public Stub createSoapClient(SoapServiceDescriptor soapServiceDescriptor) throws ServiceException {
    try {
        if (soapServiceDescriptor instanceof AxisCompatible) {
            AxisCompatible axisCompatibleService = (AxisCompatible) soapServiceDescriptor;
            EngineConfiguration engineConfiguration = engineConfigurationFactory.getClientEngineConfig();
            Service locator = (Service) axisCompatibleService.getLocatorClass().getConstructor(new Class[] { EngineConfiguration.class }).newInstance(new Object[] { engineConfiguration });
            return (Stub) locator.getClass().getMethod("getPort", Class.class).invoke(locator, soapServiceDescriptor.getInterfaceClass());
        }
        throw new ServiceException("Service [" + soapServiceDescriptor + "] not compatible with Axis", null);
    } catch (SecurityException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (NoSuchMethodException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (IllegalArgumentException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (IllegalAccessException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (InvocationTargetException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (ClassNotFoundException e) {
        throw new ServiceException("Unexpected Exception.", e);
    } catch (InstantiationException e) {
        throw new ServiceException("Unexpected Exception.", e);
    }
}
Also used : Service(org.apache.axis.client.Service) Stub(org.apache.axis.client.Stub) InvocationTargetException(java.lang.reflect.InvocationTargetException) ServiceException(com.google.api.ads.common.lib.exception.ServiceException) EngineConfiguration(org.apache.axis.EngineConfiguration) AxisCompatible(com.google.api.ads.common.lib.soap.compatability.AxisCompatible)

Aggregations

ServiceException (com.google.api.ads.common.lib.exception.ServiceException)1 AxisCompatible (com.google.api.ads.common.lib.soap.compatability.AxisCompatible)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 EngineConfiguration (org.apache.axis.EngineConfiguration)1 Service (org.apache.axis.client.Service)1 Stub (org.apache.axis.client.Stub)1