Search in sources :

Example 26 with WebServiceFeature

use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.

the class CXFServiceObjectFactoryJAXWS method getObjectInstance.

public final Object getObjectInstance(UnifiedServiceRefMetaData serviceRef) {
    try {
        // class names
        final String serviceImplClass = this.getServiceClassName(serviceRef);
        final String targetClassName = this.getTargetClassName(serviceRef);
        // class instances
        final Class<?> serviceClass = this.getClass(serviceImplClass);
        final Class<?> targetClass = this.getClass(targetClassName);
        final Service serviceInstance;
        BusFactory.setThreadDefaultBus(null);
        final Bus bus = this.createNewBus(serviceRef);
        try {
            serviceInstance = this.instantiateService(serviceRef, serviceClass);
            if (serviceRef.getHandlerChain() != null) {
                serviceInstance.setHandlerResolver(new CXFHandlerResolverImpl(bus, serviceRef.getHandlerChain(), serviceInstance.getClass()));
            }
            // construct port
            final boolean instantiatePort = targetClassName != null && !Service.class.isAssignableFrom(targetClass);
            if (instantiatePort) {
                final QName portQName = this.getPortQName(targetClassName, serviceImplClass, serviceRef);
                final WebServiceFeature[] portFeatures = this.getFeatures(targetClassName, serviceImplClass, serviceRef);
                String forcedAddress = null;
                // if there is no wsdlLocation, always use the local deployed endpoint address to initialize port
                if (getWsdlURL(serviceRef, serviceClass) == null) {
                    final QName serviceQName = this.getServiceQName(serviceRef, serviceClass);
                    forcedAddress = serviceRef.getDeployedServiceAddress(serviceQName);
                }
                return instantiatePort(serviceClass, targetClass, serviceInstance, portQName, portFeatures, forcedAddress);
            }
        } finally {
            BusFactory.setThreadDefaultBus(null);
        }
        return serviceInstance;
    } catch (Exception ex) {
        WSFException.rethrow("Cannot create service", ex);
    }
    return null;
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) WebServiceFeature(javax.xml.ws.WebServiceFeature) Service(javax.xml.ws.Service) WSFException(org.jboss.wsf.spi.WSFException) MalformedURLException(java.net.MalformedURLException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 27 with WebServiceFeature

use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.

the class CXFServiceObjectFactoryJAXWS method getFeatures.

private List<WebServiceFeature> getFeatures(final UnifiedServiceRefMetaData serviceRef) {
    List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    // configure @Addressing feature
    if (serviceRef.isAddressingAnnotationSpecified()) {
        final boolean enabled = serviceRef.isAddressingEnabled();
        final boolean required = serviceRef.isAddressingRequired();
        final String refResponses = serviceRef.getAddressingResponses();
        AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
        if ("ANONYMOUS".equals(refResponses))
            responses = AddressingFeature.Responses.ANONYMOUS;
        if ("NON_ANONYMOUS".equals(refResponses))
            responses = AddressingFeature.Responses.NON_ANONYMOUS;
        features.add(new AddressingFeature(enabled, required, responses));
    }
    // configure @MTOM feature
    if (serviceRef.isMtomAnnotationSpecified()) {
        final boolean enabled = serviceRef.isMtomEnabled();
        final int threshold = serviceRef.getMtomThreshold();
        features.add(new MTOMFeature(enabled, threshold));
    }
    // configure @RespectBinding feature
    if (serviceRef.isRespectBindingAnnotationSpecified()) {
        final boolean enabled = serviceRef.isRespectBindingEnabled();
        features.add(new RespectBindingFeature(enabled));
    }
    return features;
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) MTOMFeature(javax.xml.ws.soap.MTOMFeature) RespectBindingFeature(javax.xml.ws.RespectBindingFeature) WebServiceFeature(javax.xml.ws.WebServiceFeature) LinkedList(java.util.LinkedList) WebEndpoint(javax.xml.ws.WebEndpoint)

Example 28 with WebServiceFeature

use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.

the class CXFServiceRefStubPropertyConfigurer method setWSFeature.

private void setWSFeature(JaxWsServiceFactoryBean serviceFactoryBean, UnifiedPortComponentRefMetaData upcmd) {
    List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
    List<WebServiceFeature> prevFeatures = serviceFactoryBean.getWsFeatures();
    if (prevFeatures != null) {
        features.addAll(prevFeatures);
    }
    if (upcmd.isMtomEnabled()) {
        if (upcmd.getMtomThreshold() > 0) {
            features.add(new MTOMFeature(true, upcmd.getMtomThreshold()));
        } else {
            features.add(new MTOMFeature(true));
        }
    }
    if (upcmd.isAddressingEnabled()) {
        final String refResponses = upcmd.getAddressingResponses();
        AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
        if ("ANONYMOUS".equals(refResponses))
            responses = AddressingFeature.Responses.ANONYMOUS;
        if ("NON_ANONYMOUS".equals(refResponses))
            responses = AddressingFeature.Responses.NON_ANONYMOUS;
        features.add(new AddressingFeature(true, upcmd.isAddressingRequired(), responses));
    }
    serviceFactoryBean.setWsFeatures(features);
}
Also used : AddressingFeature(javax.xml.ws.soap.AddressingFeature) MTOMFeature(javax.xml.ws.soap.MTOMFeature) WebServiceFeature(javax.xml.ws.WebServiceFeature) LinkedList(java.util.LinkedList)

Example 29 with WebServiceFeature

use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.

the class ProviderImpl method createServiceDelegate.

@SuppressWarnings("rawtypes")
@Override
public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class serviceClass, WebServiceFeature... features) {
    // check feature types
    for (WebServiceFeature f : features) {
        final String fName = f.getClass().getName();
        if (!fName.startsWith("javax.xml.ws") && !fName.startsWith("org.jboss.ws")) {
            throw Messages.MESSAGES.unknownFeature(f.getClass().getName());
        }
    }
    final String busStrategy = ClientBusSelector.getInstance().selectStrategy(features);
    ClassLoader origClassLoader = getContextClassLoader();
    boolean restoreTCCL = false;
    Bus orig = null;
    try {
        restoreTCCL = checkAndFixContextClassLoader(origClassLoader);
        orig = BusFactory.getThreadDefaultBus(false);
        Bus bus = getOrCreateBus(busStrategy, origClassLoader);
        ServiceDelegate serviceDelegate = new JBossWSServiceImpl(bus, wsdlDocumentLocation, serviceName, serviceClass, features);
        setDisableCacheSchema(bus);
        return serviceDelegate;
    } finally {
        restoreThreadDefaultBus(busStrategy, orig);
        if (restoreTCCL)
            setContextClassLoader(origClassLoader);
    }
}
Also used : Bus(org.apache.cxf.Bus) WebServiceFeature(javax.xml.ws.WebServiceFeature) DelegateClassLoader(org.jboss.ws.common.utils.DelegateClassLoader) SecurityActions.setContextClassLoader(org.jboss.wsf.stack.cxf.client.SecurityActions.setContextClassLoader) SecurityActions.getContextClassLoader(org.jboss.wsf.stack.cxf.client.SecurityActions.getContextClassLoader) ServiceDelegate(javax.xml.ws.spi.ServiceDelegate)

Example 30 with WebServiceFeature

use of javax.xml.ws.WebServiceFeature in project jbossws-cxf by jbossws.

the class Helper method run.

public Integer run(final URL wsdlURL, final String strategyName, final int size, final int calls) {
    final WebServiceFeature feature;
    final String strategy;
    if (strategyName != null) {
        feature = convertToFeature(strategyName);
        strategy = strategyName;
    } else {
        feature = null;
        strategy = System.getProperty(Constants.JBWS_CXF_JAXWS_CLIENT_BUS_STRATEGY, null);
    }
    final BusCounter busCounter = new BusCounter();
    final ThreadFactory threadFactory = new ThreadFactory() {

        private AtomicInteger i = new AtomicInteger(0);

        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "JBWS3373-thread-" + i.getAndIncrement() + "-" + strategy);
        }
    };
    ExecutorService es = Executors.newFixedThreadPool(size, threadFactory);
    List<Client> clients = new ArrayList<Helper.Client>();
    for (int i = 0; i < calls; i++) {
        clients.add(new Client(wsdlURL, feature, busCounter));
    }
    int count = 0;
    try {
        List<Future<Boolean>> futures = es.invokeAll(clients);
        for (Future<Boolean> f : futures) {
            if (f.get()) {
                count++;
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        es.shutdown();
    }
    if (count != calls) {
        throw new RuntimeException((calls - count) + " client invocation(s) failed!");
    }
    return busCounter.getCount();
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ArrayList(java.util.ArrayList) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WebServiceFeature(javax.xml.ws.WebServiceFeature) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future)

Aggregations

WebServiceFeature (javax.xml.ws.WebServiceFeature)30 ArrayList (java.util.ArrayList)11 MTOMFeature (javax.xml.ws.soap.MTOMFeature)9 QName (javax.xml.namespace.QName)8 URL (java.net.URL)7 WebServiceException (javax.xml.ws.WebServiceException)7 AddressingFeature (javax.xml.ws.soap.AddressingFeature)7 MalformedURLException (java.net.MalformedURLException)6 RespectBindingFeature (javax.xml.ws.RespectBindingFeature)6 LinkedList (java.util.LinkedList)4 Service (javax.xml.ws.Service)4 InputStream (java.io.InputStream)3 NamingException (javax.naming.NamingException)3 DOMSource (javax.xml.transform.dom.DOMSource)3 EndpointReference (javax.xml.ws.EndpointReference)3 Bus (org.apache.cxf.Bus)3 Test (org.junit.Test)3 WSBinding (com.sun.xml.ws.api.WSBinding)2 PrivilegedActionException (java.security.PrivilegedActionException)2 Iterator (java.util.Iterator)2