Search in sources :

Example 1 with WSDLServiceBuilder

use of org.apache.cxf.wsdl11.WSDLServiceBuilder in project Activiti by Activiti.

the class CxfWSDLImporter method importFrom.

public void importFrom(String url) {
    this.wsServices.clear();
    this.wsOperations.clear();
    this.structures.clear();
    this.wsdlLocation = url;
    try {
        Bus bus = BusFactory.getDefaultBus();
        final Enumeration<URL> xjcBindingUrls = Thread.currentThread().getContextClassLoader().getResources(JAXB_BINDINGS_RESOURCE);
        if (xjcBindingUrls.hasMoreElements()) {
            final URL xjcBindingUrl = xjcBindingUrls.nextElement();
            if (xjcBindingUrls.hasMoreElements()) {
                throw new ActivitiException("Several JAXB binding definitions found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
            }
            DynamicClientFactory.newInstance(bus).createClient(url, Arrays.asList(new String[] { xjcBindingUrl.toString() }));
            WSDLManager wsdlManager = bus.getExtension(WSDLManager.class);
            Definition def = wsdlManager.getDefinition(url);
            WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
            List<ServiceInfo> services = builder.buildServices(def);
            for (ServiceInfo service : services) {
                WSService wsService = this.importService(service);
                this.wsServices.put(this.namespace + wsService.getName(), wsService);
            }
            if (def != null && def.getTypes() != null) {
                this.importTypes(def.getTypes());
            }
        } else {
            throw new ActivitiException("The JAXB binding definitions are not found for activiti-cxf: " + JAXB_BINDINGS_RESOURCE);
        }
    } catch (WSDLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        throw new ActivitiException("Error retrieveing the JAXB binding definitions", e);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActivitiException(org.activiti.engine.ActivitiException) WSDLException(javax.wsdl.WSDLException) StructureDefinition(org.activiti.engine.impl.bpmn.data.StructureDefinition) SimpleStructureDefinition(org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition) Definition(javax.wsdl.Definition) PrimitiveStructureDefinition(org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition) IOException(java.io.IOException) URL(java.net.URL) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager)

Aggregations

IOException (java.io.IOException)1 URL (java.net.URL)1 Definition (javax.wsdl.Definition)1 WSDLException (javax.wsdl.WSDLException)1 ActivitiException (org.activiti.engine.ActivitiException)1 PrimitiveStructureDefinition (org.activiti.engine.impl.bpmn.data.PrimitiveStructureDefinition)1 SimpleStructureDefinition (org.activiti.engine.impl.bpmn.data.SimpleStructureDefinition)1 StructureDefinition (org.activiti.engine.impl.bpmn.data.StructureDefinition)1 Bus (org.apache.cxf.Bus)1 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)1 WSDLManager (org.apache.cxf.wsdl.WSDLManager)1 WSDLServiceBuilder (org.apache.cxf.wsdl11.WSDLServiceBuilder)1