Search in sources :

Example 6 with WSDLServiceFactory

use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.

the class ReflectionServiceFactoryBean method buildServiceFromWSDL.

protected void buildServiceFromWSDL(String url) {
    sendEvent(Event.CREATE_FROM_WSDL, url);
    if (LOG.isLoggable(Level.INFO)) {
        LOG.info("Creating Service " + getServiceQName() + " from WSDL: " + url);
    }
    populateFromClass = false;
    WSDLServiceFactory factory = new WSDLServiceFactory(getBus(), url, getServiceQName());
    boolean setEPName = true;
    if (features != null) {
        for (Feature f : features) {
            if (f.getClass().isAnnotationPresent(EvaluateAllEndpoints.class)) {
                setEPName = false;
            }
        }
    }
    if (setEPName) {
        // CXF will only evaluate this endpoint
        factory.setEndpointName(getEndpointName(false));
    }
    sendEvent(Event.WSDL_LOADED, factory.getDefinition());
    setService(factory.create());
    setServiceProperties();
    sendEvent(Event.SERVICE_SET, getService());
    EndpointInfo epInfo = getEndpointInfo();
    if (epInfo != null) {
        serviceConfigurations.add(new WSDLBasedServiceConfiguration(getEndpointInfo().getBinding()));
    }
    initializeWSDLOperations();
    Set<Class<?>> cls = getExtraClass();
    if (cls != null && !cls.isEmpty()) {
        for (ServiceInfo si : getService().getServiceInfos()) {
            si.setProperty(EXTRA_CLASS, cls);
        }
    }
    initializeDataBindings();
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) Feature(org.apache.cxf.feature.Feature)

Example 7 with WSDLServiceFactory

use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.

the class SimpleBatchSTSClient method createClient.

protected void createClient() throws BusException, EndpointException {
    if (client != null) {
        return;
    }
    bus.getExtension(Configurer.class).configureBean(name, this);
    if (wsdlLocation != null) {
        WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlLocation, serviceName);
        SourceDataBinding dataBinding = new SourceDataBinding();
        factory.setDataBinding(dataBinding);
        Service service = factory.create();
        service.setDataBinding(dataBinding);
        EndpointInfo ei = service.getEndpointInfo(endpointName);
        Endpoint endpoint = new EndpointImpl(bus, service, ei);
        client = new ClientImpl(bus, endpoint);
    } else {
        Endpoint endpoint = STSUtils.createSTSEndpoint(bus, namespace, null, location, soapVersion, policy, endpointName);
        client = new ClientImpl(bus, endpoint);
    }
    client.getInFaultInterceptors().addAll(inFault);
    client.getInInterceptors().addAll(in);
    client.getOutInterceptors().addAll(out);
    client.getOutFaultInterceptors().addAll(outFault);
    in = null;
    out = null;
    inFault = null;
    outFault = null;
    if (features != null) {
        for (AbstractFeature f : features) {
            f.initialize(client, bus);
        }
    }
}
Also used : EndpointInfo(org.apache.cxf.service.model.EndpointInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) Endpoint(org.apache.cxf.endpoint.Endpoint) EndpointImpl(org.apache.cxf.endpoint.EndpointImpl) Service(org.apache.cxf.service.Service) ClientImpl(org.apache.cxf.endpoint.ClientImpl) AbstractFeature(org.apache.cxf.feature.AbstractFeature) Configurer(org.apache.cxf.configuration.Configurer) SourceDataBinding(org.apache.cxf.databinding.source.SourceDataBinding)

Example 8 with WSDLServiceFactory

use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.

the class ServiceImpl method initializePorts.

private void initializePorts() {
    try {
        Definition def = bus.getExtension(WSDLManager.class).getDefinition(wsdlURL);
        javax.wsdl.Service serv = def.getService(serviceName);
        if (serv == null) {
            throw new WebServiceException("Could not find service named " + serviceName + " in wsdl " + wsdlURL);
        }
        Map<String, Port> wsdlports = CastUtils.cast(serv.getPorts());
        for (Port port : wsdlports.values()) {
            QName name = new QName(serviceName.getNamespaceURI(), port.getName());
            String address = null;
            String bindingID = null;
            List<? extends ExtensibilityElement> extensions = CastUtils.cast(port.getBinding().getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                } else if (e instanceof SOAP12Binding) {
                    bindingID = SOAPBinding.SOAP12HTTP_BINDING;
                } else if (e instanceof javax.wsdl.extensions.soap.SOAPBinding) {
                    bindingID = SOAPBinding.SOAP11HTTP_BINDING;
                }
            }
            extensions = CastUtils.cast(port.getExtensibilityElements());
            if (!extensions.isEmpty()) {
                ExtensibilityElement e = extensions.get(0);
                if (e instanceof SoapAddress) {
                    address = ((SoapAddress) e).getLocationURI();
                } else if (e instanceof AddressType) {
                    address = ((AddressType) e).getLocation();
                } else if (e instanceof SOAP12Address) {
                    address = ((SOAP12Address) e).getLocationURI();
                } else if (e instanceof SOAPAddress) {
                    address = ((SOAPAddress) e).getLocationURI();
                } else if (e instanceof HTTPAddress) {
                    address = ((HTTPAddress) e).getLocationURI();
                }
            }
            addPort(name, bindingID, address);
        }
    } catch (WebServiceException e) {
        throw e;
    } catch (Throwable e) {
        if (e instanceof UncheckedException && LOG.isLoggable(Level.FINE)) {
            LOG.log(Level.FINE, e.getLocalizedMessage(), e);
        }
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        Service service = sf.create();
        for (ServiceInfo si : service.getServiceInfos()) {
            for (EndpointInfo ei : si.getEndpoints()) {
                String bindingID = BindingID.getJaxwsBindingID(ei.getTransportId());
                addPort(ei.getName(), bindingID, ei.getAddress());
            }
        }
    }
}
Also used : HTTPAddress(javax.wsdl.extensions.http.HTTPAddress) Port(javax.wsdl.Port) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) WebServiceException(javax.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) SoapBinding(org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding) UncheckedException(org.apache.cxf.common.i18n.UncheckedException) SoapAddress(org.apache.cxf.binding.soap.wsdl.extensions.SoapAddress) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLManager(org.apache.cxf.wsdl.WSDLManager) AddressType(org.apache.cxf.wsdl.http.AddressType)

Example 9 with WSDLServiceFactory

use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.

the class ServiceImpl method createDispatchService.

private AbstractServiceFactoryBean createDispatchService(DataBinding db) {
    AbstractServiceFactoryBean serviceFactory;
    Service dispatchService = null;
    if (null != wsdlURL) {
        WSDLServiceFactory sf = new WSDLServiceFactory(bus, wsdlURL, serviceName);
        dispatchService = sf.create();
        dispatchService.setDataBinding(db);
        serviceFactory = sf;
    } else {
        ReflectionServiceFactoryBean sf = new JaxWsServiceFactoryBean();
        sf.setBus(bus);
        sf.setServiceName(serviceName);
        // maybe we can find another way to create service which have no SEI
        sf.setServiceClass(DummyImpl.class);
        sf.setDataBinding(db);
        dispatchService = sf.create();
        serviceFactory = sf;
    }
    configureObject(dispatchService);
    for (ServiceInfo si : dispatchService.getServiceInfos()) {
        si.setProperty("soap.force.doclit.bare", Boolean.TRUE);
        if (null == wsdlURL) {
            for (EndpointInfo ei : si.getEndpoints()) {
                ei.setProperty("soap.no.validate.parts", Boolean.TRUE);
            }
        }
        for (BindingInfo bind : si.getBindings()) {
            for (BindingOperationInfo bop : bind.getOperations()) {
                // force to bare, no unwrapping
                if (bop.isUnwrappedCapable()) {
                    bop.getOperationInfo().setUnwrappedOperation(null);
                    bop.setUnwrappedOperation(null);
                }
            }
        }
    }
    return serviceFactory;
}
Also used : AbstractServiceFactoryBean(org.apache.cxf.service.factory.AbstractServiceFactoryBean) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) JaxWsServiceFactoryBean(org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean) BindingInfo(org.apache.cxf.service.model.BindingInfo) Service(org.apache.cxf.service.Service) WebService(javax.jws.WebService) ReflectionServiceFactoryBean(org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)

Example 10 with WSDLServiceFactory

use of org.apache.cxf.wsdl11.WSDLServiceFactory in project cxf by apache.

the class AbstractJMSTester method setupServiceInfo.

protected EndpointInfo setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
    URL wsdlUrl = getClass().getResource(wsdl);
    if (wsdlUrl == null) {
        throw new IllegalArgumentException("Wsdl file not found on class path " + wsdl);
    }
    WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl.toExternalForm(), new QName(ns, serviceName));
    Service service = factory.create();
    return service.getEndpointInfo(new QName(ns, portName));
}
Also used : WSDLServiceFactory(org.apache.cxf.wsdl11.WSDLServiceFactory) QName(javax.xml.namespace.QName) Service(org.apache.cxf.service.Service) BrokerService(org.apache.activemq.broker.BrokerService) URL(java.net.URL)

Aggregations

WSDLServiceFactory (org.apache.cxf.wsdl11.WSDLServiceFactory)19 QName (javax.xml.namespace.QName)14 Service (org.apache.cxf.service.Service)12 EndpointImpl (org.apache.cxf.endpoint.EndpointImpl)8 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)7 URL (java.net.URL)6 Exchange (org.apache.cxf.message.Exchange)5 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)5 MessageImpl (org.apache.cxf.message.MessageImpl)5 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)5 SourceDataBinding (org.apache.cxf.databinding.source.SourceDataBinding)4 ClientImpl (org.apache.cxf.endpoint.ClientImpl)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Definition (javax.wsdl.Definition)3 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)3 WSDLManager (org.apache.cxf.wsdl.WSDLManager)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 WebService (javax.jws.WebService)2 Schema (javax.wsdl.extensions.schema.Schema)2