Search in sources :

Example 1 with GeneratedNamespaceClassLoader

use of org.apache.cxf.common.spi.GeneratedNamespaceClassLoader in project quarkus-cxf by quarkiverse.

the class CxfClientProducer method produceCxfClient.

/**
 * The main workhorse producing a CXF client proxy.
 *
 * @param cxfClientInfo
 * @return
 */
private Object produceCxfClient(CXFClientInfo cxfClientInfo) {
    Class<?> seiClass;
    try {
        seiClass = Class.forName(cxfClientInfo.getSei(), false, Thread.currentThread().getContextClassLoader());
    } catch (ClassNotFoundException e) {
        LOGGER.error("either webservice interface (client) or implementation (server) is mandatory");
        return null;
    }
    QuarkusClientFactoryBean quarkusClientFactoryBean = new QuarkusClientFactoryBean(cxfClientInfo.getClassNames());
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(quarkusClientFactoryBean);
    Bus bus = quarkusClientFactoryBean.getBus(true);
    bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
    bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
    bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
    bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
    bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
    bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
    factory.setServiceClass(seiClass);
    LOGGER.debugf("using servicename {%s}%s", cxfClientInfo.getWsNamespace(), cxfClientInfo.getWsName());
    factory.setServiceName(new QName(cxfClientInfo.getWsNamespace(), cxfClientInfo.getWsName()));
    if (cxfClientInfo.getEpName() != null) {
        factory.setEndpointName(new QName(cxfClientInfo.getEpNamespace(), cxfClientInfo.getEpName()));
    }
    factory.setAddress(cxfClientInfo.getEndpointAddress());
    if (cxfClientInfo.getSoapBinding() != null) {
        factory.setBindingId(cxfClientInfo.getSoapBinding());
    }
    if (cxfClientInfo.getWsdlUrl() != null && !cxfClientInfo.getWsdlUrl().isEmpty()) {
        factory.setWsdlURL(cxfClientInfo.getWsdlUrl());
    }
    if (cxfClientInfo.getUsername() != null) {
        factory.setUsername(cxfClientInfo.getUsername());
    }
    if (cxfClientInfo.getPassword() != null) {
        factory.setPassword(cxfClientInfo.getPassword());
    }
    for (String feature : cxfClientInfo.getFeatures()) {
        addToCols(feature, factory.getFeatures(), Feature.class);
    }
    for (String handler : cxfClientInfo.getHandlers()) {
        addToCols(handler, factory.getHandlers(), Handler.class);
    }
    for (String inInterceptor : cxfClientInfo.getInInterceptors()) {
        addToCols(inInterceptor, factory.getInInterceptors());
    }
    for (String outInterceptor : cxfClientInfo.getOutInterceptors()) {
        addToCols(outInterceptor, factory.getOutInterceptors());
    }
    for (String outFaultInterceptor : cxfClientInfo.getOutFaultInterceptors()) {
        addToCols(outFaultInterceptor, factory.getOutFaultInterceptors());
    }
    for (String inFaultInterceptor : cxfClientInfo.getInFaultInterceptors()) {
        addToCols(inFaultInterceptor, factory.getInFaultInterceptors());
    }
    LOGGER.debug("cxf client loaded for " + cxfClientInfo.getSei());
    return factory.create();
}
Also used : Bus(org.apache.cxf.Bus) FactoryClassLoader(org.apache.cxf.jaxb.FactoryClassLoader) ExtensionClassLoader(org.apache.cxf.wsdl.ExtensionClassLoader) QName(javax.xml.namespace.QName) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) ExceptionClassLoader(org.apache.cxf.endpoint.dynamic.ExceptionClassLoader) GeneratedNamespaceClassLoader(org.apache.cxf.common.spi.GeneratedNamespaceClassLoader) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) WrapperClassLoader(org.apache.cxf.jaxws.spi.WrapperClassLoader)

Example 2 with GeneratedNamespaceClassLoader

use of org.apache.cxf.common.spi.GeneratedNamespaceClassLoader in project cxf by apache.

the class Client method main.

public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.err.println("please provide wsdl");
        System.exit(0);
    }
    final Bus bus = new ExtensionManagerBus();
    BusFactory.setDefaultBus(bus);
    bus.setExtension(new WrapperHelperClassLoader(bus), WrapperHelperCreator.class);
    bus.setExtension(new ExtensionClassLoader(bus), ExtensionClassCreator.class);
    bus.setExtension(new ExceptionClassLoader(bus), ExceptionClassCreator.class);
    bus.setExtension(new WrapperClassLoader(bus), WrapperClassCreator.class);
    bus.setExtension(new FactoryClassLoader(bus), FactoryClassCreator.class);
    bus.setExtension(new GeneratedNamespaceClassLoader(bus), NamespaceClassCreator.class);
    run(args, bus);
    System.exit(0);
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) FactoryClassLoader(org.apache.cxf.jaxb.FactoryClassLoader) ExtensionClassLoader(org.apache.cxf.wsdl.ExtensionClassLoader) GeneratedNamespaceClassLoader(org.apache.cxf.common.spi.GeneratedNamespaceClassLoader) WrapperHelperClassLoader(org.apache.cxf.jaxb.WrapperHelperClassLoader) ExceptionClassLoader(org.apache.cxf.endpoint.dynamic.ExceptionClassLoader) WrapperClassLoader(org.apache.cxf.jaxws.spi.WrapperClassLoader) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus)

Aggregations

Bus (org.apache.cxf.Bus)2 GeneratedNamespaceClassLoader (org.apache.cxf.common.spi.GeneratedNamespaceClassLoader)2 ExceptionClassLoader (org.apache.cxf.endpoint.dynamic.ExceptionClassLoader)2 FactoryClassLoader (org.apache.cxf.jaxb.FactoryClassLoader)2 WrapperHelperClassLoader (org.apache.cxf.jaxb.WrapperHelperClassLoader)2 WrapperClassLoader (org.apache.cxf.jaxws.spi.WrapperClassLoader)2 ExtensionClassLoader (org.apache.cxf.wsdl.ExtensionClassLoader)2 QName (javax.xml.namespace.QName)1 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)1 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)1