Search in sources :

Example 1 with DescriptionInfo

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

the class WSDLServiceBuilder method buildBinding.

public BindingInfo buildBinding(ServiceInfo service, Binding binding) {
    BindingInfo bi = null;
    StringBuilder ns = new StringBuilder(100);
    BindingFactory factory = WSDLServiceUtils.getBindingFactory(binding, bus, ns);
    if (factory instanceof WSDLBindingFactory) {
        WSDLBindingFactory wFactory = (WSDLBindingFactory) factory;
        bi = wFactory.createBindingInfo(service, binding, ns.toString());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
    }
    if (bi == null) {
        boolean onlyExtensors = false;
        if (factory instanceof AbstractBindingFactory) {
            bi = ((AbstractBindingFactory) factory).createBindingInfo(service, ns.toString(), null);
            onlyExtensors = true;
        } else {
            bi = new BindingInfo(service, ns.toString());
        }
        bi.setName(binding.getQName());
        copyExtensors(bi, binding.getExtensibilityElements());
        copyExtensionAttributes(bi, binding);
        for (BindingOperation bop : cast(binding.getBindingOperations(), BindingOperation.class)) {
            if (LOG.isLoggable(Level.FINER)) {
                LOG.finer("binding operation name is " + bop.getName());
            }
            String inName = null;
            String outName = null;
            if (bop.getBindingInput() != null) {
                inName = bop.getBindingInput().getName();
            }
            if (bop.getBindingOutput() != null) {
                outName = bop.getBindingOutput().getName();
            }
            BindingOperationInfo bop2 = null;
            if (onlyExtensors) {
                bop2 = bi.getOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()));
            } else {
                bop2 = bi.buildOperation(new QName(binding.getQName().getNamespaceURI(), bop.getName()), inName, outName);
                if (bop2 != null) {
                    bi.addOperation(bop2);
                }
            }
            if (bop2 != null) {
                copyExtensors(bop2, bop.getExtensibilityElements());
                copyExtensionAttributes(bop2, bop);
                if (bop.getBindingInput() != null) {
                    copyExtensors(bop2.getInput(), bop.getBindingInput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getInput(), bop.getBindingInput());
                    handleHeader(bop2.getInput());
                }
                if (bop.getBindingOutput() != null) {
                    copyExtensors(bop2.getOutput(), bop.getBindingOutput().getExtensibilityElements());
                    copyExtensionAttributes(bop2.getOutput(), bop.getBindingOutput());
                    handleHeader(bop2.getOutput());
                }
                for (BindingFault f : cast(bop.getBindingFaults().values(), BindingFault.class)) {
                    BindingFaultInfo bif = bop2.getFault(new QName(service.getTargetNamespace(), f.getName()));
                    copyExtensors(bif, bop.getBindingFault(f.getName()).getExtensibilityElements());
                    copyExtensionAttributes(bif, bop.getBindingFault(f.getName()));
                }
            }
        }
    }
    service.addBinding(bi);
    DescriptionInfo d = service.getDescription();
    if (null != d) {
        d.getDescribed().add(bi);
    }
    return bi;
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) BindingFault(javax.wsdl.BindingFault) QName(javax.xml.namespace.QName) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingOperation(javax.wsdl.BindingOperation) BindingInfo(org.apache.cxf.service.model.BindingInfo) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) WSDLBindingFactory(org.apache.cxf.wsdl.binding.WSDLBindingFactory) AbstractBindingFactory(org.apache.cxf.binding.AbstractBindingFactory) BindingFactory(org.apache.cxf.binding.BindingFactory)

Example 2 with DescriptionInfo

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

/**
 * The effective policy for a specific WSDL message (input or output) is calculated
 * in relation to a specific port, and includes the element policy of the wsdl:message
 * element that defines the message's type merged with the element policy of the
 * wsdl11:binding and wsdl11:portType message definitions that describe the message.
 * For example, the effective policy of a specific input message for a specific port
 * would be the (element policies of the) wsdl11:message element defining the message type,
 * the wsdl11:portType/wsdl11:operation/wsdl11:input element and the corresponding
 * wsdl11:binding/wsdl11:operation/wsdl11:input element for that message.
 *
 * @param bmi the BindingMessageInfo identifiying the message
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingMessageInfo bmi, Message m) {
    ServiceInfo si = bmi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bmi, false, di);
    MessageInfo mi = bmi.getMessageInfo();
    p = mergePolicies(p, getElementPolicy(mi, true, di));
    Extensible ex = getMessageTypeInfo(mi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) MessageInfo(org.apache.cxf.service.model.MessageInfo) BindingMessageInfo(org.apache.cxf.service.model.BindingMessageInfo)

Example 3 with DescriptionInfo

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

/**
 * The effective policy for a WSDL operation policy subject is calculated in relation to a
 * specific port, and includes the element policy of the wsdl11:portType/wsdl11:operation
 * element that defines the operation merged with that of the corresponding
 * wsdl11:binding/wsdl11:operation element.
 *
 * @param bi the BindingOperationInfo identifying the operation in relation to a port
 * @return the effective policy
 */
public Policy getEffectivePolicy(BindingOperationInfo bi, Message m) {
    DescriptionInfo di = bi.getBinding().getDescription();
    Policy p = getElementPolicy(bi, false, di);
    p = mergePolicies(p, getElementPolicy(bi.getOperationInfo(), false, di));
    return p;
}
Also used : Policy(org.apache.neethi.Policy) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 4 with DescriptionInfo

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

the class Wsdl11AttachmentPolicyProvider method getEffectivePolicy.

public Policy getEffectivePolicy(BindingFaultInfo bfi, Message m) {
    ServiceInfo si = bfi.getBindingOperation().getBinding().getService();
    DescriptionInfo di = si.getDescription();
    Policy p = getElementPolicy(bfi, false, di);
    FaultInfo fi = bfi.getFaultInfo();
    p = mergePolicies(p, getElementPolicy(fi, true, di));
    Extensible ex = getMessageTypeInfo(fi.getName(), di);
    p = mergePolicies(p, getElementPolicy(ex, false, di));
    return p;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Policy(org.apache.neethi.Policy) BindingFaultInfo(org.apache.cxf.service.model.BindingFaultInfo) FaultInfo(org.apache.cxf.service.model.FaultInfo) Extensible(org.apache.cxf.service.model.Extensible) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo)

Example 5 with DescriptionInfo

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

the class JaxWsEndpointImpl method buildWsdlExtensibilities.

private void buildWsdlExtensibilities(BindingInfo bindingInfo) {
    Addressing addressing = getAddressing();
    if (addressing != null) {
        ExtensionRegistry extensionRegistry = getBus().getExtension(WSDLManager.class).getExtensionRegistry();
        try {
            ExtensibilityElement el = extensionRegistry.createExtension(javax.wsdl.Binding.class, JAXWSAConstants.WSAW_USINGADDRESSING_QNAME);
            el.setRequired(addressing.required());
            bindingInfo.addExtensor(el);
            StringBuilder polRefId = new StringBuilder(bindingInfo.getName().getLocalPart());
            polRefId.append("_WSAM_Addressing_Policy");
            UnknownExtensibilityElement uel = new UnknownExtensibilityElement();
            W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
            writer.writeStartElement("wsp", "PolicyReference", URI_POLICY_NS);
            writer.writeAttribute("URI", "#" + polRefId.toString());
            writer.writeEndElement();
            Element pr = writer.getDocument().getDocumentElement();
            uel.setElement(pr);
            uel.setElementType(DOMUtils.getElementQName(pr));
            bindingInfo.addExtensor(uel);
            writer = new W3CDOMStreamWriter();
            writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
            writer.writeAttribute("wsu", URI_WSU_NS, "Id", polRefId.toString());
            writer.writeStartElement("wsam", "Addressing", JAXWSAConstants.NS_WSAM);
            if (!addressing.required()) {
                writer.writeAttribute("wsp", URI_POLICY_NS, "Optional", "true");
            }
            writer.writeStartElement("wsp", "Policy", URI_POLICY_NS);
            String s = getAddressingRequirement(addressing);
            if (s != null) {
                writer.writeEmptyElement("wsam", s, JAXWSAConstants.NS_WSAM);
            }
            writer.writeEndElement();
            writer.writeEndElement();
            writer.writeEndElement();
            pr = writer.getDocument().getDocumentElement();
            uel = new UnknownExtensibilityElement();
            uel.setElement(pr);
            uel.setElementType(DOMUtils.getElementQName(pr));
            if (bindingInfo.getService().getDescription() == null) {
                DescriptionInfo description = new DescriptionInfo();
                description.setName(bindingInfo.getService().getName());
                bindingInfo.getService().setDescription(description);
            }
            bindingInfo.getService().getDescription().addExtensor(uel);
        } catch (Exception e) {
            // ignore
            e.printStackTrace();
        }
    }
}
Also used : W3CDOMStreamWriter(org.apache.cxf.staxutils.W3CDOMStreamWriter) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) WSDLManager(org.apache.cxf.wsdl.WSDLManager) DescriptionInfo(org.apache.cxf.service.model.DescriptionInfo) Addressing(javax.xml.ws.soap.Addressing) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) WebServiceException(javax.xml.ws.WebServiceException) EndpointException(org.apache.cxf.endpoint.EndpointException) ExtensionRegistry(javax.wsdl.extensions.ExtensionRegistry)

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