Search in sources :

Example 11 with DescriptionInfo

use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.

the class WSDLServiceBuilder method buildMockServices.

public List<ServiceInfo> buildMockServices(Definition d) {
    List<ServiceInfo> serviceList = new ArrayList<>();
    List<Definition> defList = new ArrayList<>();
    defList.add(d);
    parseImports(d, defList);
    for (Definition def : defList) {
        for (Iterator<?> ite = def.getPortTypes().entrySet().iterator(); ite.hasNext(); ) {
            Entry<?, ?> entry = (Entry<?, ?>) ite.next();
            PortType portType = def.getPortType((QName) entry.getKey());
            ServiceInfo serviceInfo = this.buildMockService(def, portType);
            serviceList.add(serviceInfo);
            for (Iterator<?> it2 = d.getAllBindings().values().iterator(); it2.hasNext(); ) {
                Binding b = (Binding) it2.next();
                if (b.getPortType() == portType) {
                    this.buildBinding(serviceInfo, b);
                    break;
                }
            }
        }
        if (def.getPortTypes().isEmpty()) {
            DescriptionInfo description = new DescriptionInfo();
            if (recordOriginal) {
                description.setProperty(WSDL_DEFINITION, def);
            }
            description.setName(def.getQName());
            description.setBaseURI(def.getDocumentBaseURI());
            copyExtensors(description, def.getExtensibilityElements());
            copyExtensionAttributes(description, def);
            ServiceInfo service = new ServiceInfo();
            service.setDescription(description);
            if (recordOriginal) {
                service.setProperty(WSDL_DEFINITION, def);
            }
            getSchemas(def, service);
            service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
            serviceList.add(service);
        }
    }
    return serviceList;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) Definition(javax.wsdl.Definition) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PortType(javax.wsdl.PortType)

Example 12 with DescriptionInfo

use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.

the class WSDLServiceBuilder method buildServices.

private List<ServiceInfo> buildServices(Definition def, Service serv, QName endpointName, DescriptionInfo d) {
    Map<QName, ServiceInfo> services = new LinkedHashMap<QName, ServiceInfo>();
    DescriptionInfo description = d;
    if (null == description) {
        description = new DescriptionInfo();
        if (recordOriginal) {
            description.setProperty(WSDL_DEFINITION, def);
        }
        description.setName(def.getQName());
        description.setBaseURI(def.getDocumentBaseURI());
        copyExtensors(description, def.getExtensibilityElements());
        copyExtensionAttributes(description, def);
        Set<Definition> done = new HashSet<>();
        done.add(def);
        Collection<List<Import>> values = CastUtils.cast(def.getImports().values());
        for (List<Import> imports : values) {
            for (Import imp : imports) {
                if (!done.contains(imp.getDefinition())) {
                    done.add(imp.getDefinition());
                    copyExtensors(description, imp.getExtensibilityElements());
                    copyExtensionAttributes(description, imp);
                    copyExtensors(description, imp.getDefinition().getExtensibilityElements());
                    copyExtensionAttributes(description, imp.getDefinition());
                }
            }
        }
    }
    for (Port port : cast(serv.getPorts().values(), Port.class)) {
        if (endpointName != null && !endpointName.getLocalPart().equals(port.getName())) {
            continue;
        }
        Binding binding = port.getBinding();
        PortType bindingPt = binding.getPortType();
        if (bindingPt == null) {
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("BINDING_MISSING_TYPE", LOG, binding.getQName());
            throw new WSDLRuntimeException(msg);
        }
        // TODO: wsdl4j's bug. if there is recursive import,
        // wsdl4j can not get operation input message
        PortType pt = def.getPortType(bindingPt.getQName());
        if (pt == null) {
            pt = bindingPt;
        }
        ServiceInfo service = services.get(pt.getQName());
        if (service == null) {
            service = new ServiceInfo();
            service.setDescription(description);
            description.getDescribed().add(service);
            if (recordOriginal) {
                service.setProperty(WSDL_DEFINITION, def);
                service.setProperty(WSDL_SERVICE, serv);
            }
            getSchemas(def, service);
            copyDocumentation(service, serv);
            service.setProperty(WSDL_SCHEMA_ELEMENT_LIST, this.schemaList);
            service.setTargetNamespace(def.getTargetNamespace());
            service.setName(serv.getQName());
            copyExtensors(service, serv.getExtensibilityElements());
            copyExtensionAttributes(service, serv);
            buildInterface(service, pt);
            services.put(pt.getQName(), service);
        }
        BindingInfo bi = service.getBinding(binding.getQName());
        if (bi == null) {
            bi = buildBinding(service, binding);
        }
        buildEndpoint(service, bi, port);
    }
    return new ArrayList<>(services.values());
}
Also used : Import(javax.wsdl.Import) Message(javax.wsdl.Message) Port(javax.wsdl.Port) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) BindingInfo(org.apache.cxf.service.model.BindingInfo) List(java.util.List) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PortType(javax.wsdl.PortType)

Example 13 with DescriptionInfo

use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.

the class WSDLServiceBuilder method buildInterface.

public void buildInterface(ServiceInfo si, PortType p) {
    InterfaceInfo inf = si.createInterface(p.getQName());
    DescriptionInfo d = si.getDescription();
    if (null != d) {
        d.getDescribed().add(inf);
    }
    copyDocumentation(inf, p);
    this.copyExtensors(inf, p.getExtensibilityElements());
    this.copyExtensionAttributes(inf, p);
    if (recordOriginal) {
        inf.setProperty(WSDL_PORTTYPE, p);
    }
    for (Operation op : cast(p.getOperations(), Operation.class)) {
        buildInterfaceOperation(inf, op);
    }
}
Also used : DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation)

Example 14 with DescriptionInfo

use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.

the class ServiceModelPolicyUpdater method addPolicy.

private void addPolicy(PolicyAttachment pa) {
    // TODO - do I need to defensively copy this?
    Element policyEl = pa.getElement();
    UnknownExtensibilityElement uee = new UnknownExtensibilityElement();
    uee.setRequired(true);
    uee.setElementType(DOMUtils.getElementQName(policyEl));
    uee.setElement(policyEl);
    if (ei.getService().getDescription() == null) {
        DescriptionInfo description = new DescriptionInfo();
        description.setName(ei.getService().getName());
        if (!StringUtils.isEmpty(ei.getAddress())) {
            description.setBaseURI(ei.getAddress() + "?wsdl");
        }
        ei.getService().setDescription(description);
    }
    ei.getService().getDescription().addExtensor(uee);
}
Also used : UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) Element(org.w3c.dom.Element) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 15 with DescriptionInfo

use of org.apache.cxf.service.model.DescriptionInfo in project cxf by apache.

the class WSPolicyFeature method initializeEndpointPolicy.

private Policy initializeEndpointPolicy(Endpoint endpoint, Bus bus) {
    initialize(bus);
    DescriptionInfo i = endpoint.getEndpointInfo().getDescription();
    Collection<Policy> loadedPolicies = null;
    if (policyElements != null || policyReferenceElements != null) {
        loadedPolicies = new ArrayList<>();
        PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
        if (null != policyElements) {
            for (Element e : policyElements) {
                loadedPolicies.add(builder.getPolicy(e));
            }
        }
        if (null != policyReferenceElements) {
            for (Element e : policyReferenceElements) {
                PolicyReference pr = builder.getPolicyReference(e);
                Policy resolved = resolveReference(pr, builder, bus, i);
                if (null != resolved) {
                    loadedPolicies.add(resolved);
                }
            }
        }
    }
    Policy thePolicy = new Policy();
    if (policies != null) {
        for (Policy p : policies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    if (loadedPolicies != null) {
        for (Policy p : loadedPolicies) {
            thePolicy = thePolicy.merge(p);
        }
    }
    return thePolicy;
}
Also used : Policy(org.apache.neethi.Policy) Element(org.w3c.dom.Element) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) PolicyReference(org.apache.neethi.PolicyReference)

Aggregations

DescriptionInfo (org.apache.cxf.service.model.DescriptionInfo)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)6 QName (javax.xml.namespace.QName)5 Policy (org.apache.neethi.Policy)5 Element (org.w3c.dom.Element)5 ArrayList (java.util.ArrayList)4 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)4 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)3 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)3 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 Definition (javax.wsdl.Definition)2 Message (javax.wsdl.Message)2 PortType (javax.wsdl.PortType)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 BindingFaultInfo (org.apache.cxf.service.model.BindingFaultInfo)2 BindingInfo (org.apache.cxf.service.model.BindingInfo)2 Extensible (org.apache.cxf.service.model.Extensible)2 URL (java.net.URL)1 HashSet (java.util.HashSet)1