Search in sources :

Example 36 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class WSDLToIDLAction method collectIdlDefns.

private void collectIdlDefns(Binding binding) throws Exception {
    boolean isOneway = false;
    Iterator<?> iterator = binding.getBindingOperations().iterator();
    while (iterator.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) iterator.next();
        if (bindingOperation.getBindingOutput() == null) {
            isOneway = true;
        }
        addOperation(bindingOperation, isOneway);
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation)

Example 37 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class OperationVisitor method visit.

public void visit(AST node) {
    // <op_dcl> ::= [<op_attribute>] <op_type_spec>
    // <identifier> <parameter_dcls>
    // [<raises_expr>] [<context_expr>]
    // <op_attribute> ::= "oneway"
    // <op_type_spec> ::= <param_type_spec>
    // | "void"
    // <parameter_dcls> ::= "(" <param_dcl> {"," <param_dcl>}* ")"
    // | "(" ")"
    // <raises_expr> ::= "raises" "(" <scoped_name> {"," <scoped_name>}* ")"
    // <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"
    QName operationQName = new QName(schema.getTargetNamespace(), node.toString());
    boolean isDuplicate = false;
    if (schema.getElements().containsKey(operationQName)) {
        isDuplicate = true;
    }
    Operation operation = generateOperation(operationQName.getLocalPart(), isDuplicate);
    BindingOperation bindingOperation = null;
    if (isDuplicate) {
        bindingOperation = generateBindingOperation(binding, operation, operationQName.getLocalPart());
    } else {
        bindingOperation = generateBindingOperation(binding, operation, operation.getName());
    }
    XmlSchemaSequence inputWrappingSequence = new XmlSchemaSequence();
    XmlSchemaElement inputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName()), inputWrappingSequence);
    inputMsg = generateInputMessage(operation, bindingOperation);
    generateInputPart(inputMsg, inputElement);
    // <op_attribute>
    node = node.getFirstChild();
    XmlSchemaSequence outputWrappingSequence = null;
    XmlSchemaElement outputElement = null;
    if (node != null && (node.getType() == IDLTokenTypes.LITERAL_oneway)) {
        // oneway operations map to operations with only input message
        // no outputMsg nor outputPart need be created
        node = node.getNextSibling();
    } else {
        // normal operations map to request-response operations
        // with input and output messages
        outputWrappingSequence = new XmlSchemaSequence();
        outputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName() + RESPONSE_SUFFIX), outputWrappingSequence);
        outputMsg = generateOutputMessage(operation, bindingOperation);
        generateOutputPart(outputMsg, outputElement);
    }
    // <op_type_spec>
    visitOpTypeSpec(node, outputWrappingSequence);
    // <parameter_dcls>
    node = TypesUtils.getCorbaTypeNameNode(node);
    while (ParamDclVisitor.accept(node)) {
        ParamDclVisitor visitor = new ParamDclVisitor(getScope(), definition, schema, wsdlVisitor, inputWrappingSequence, outputWrappingSequence, corbaOperation);
        visitor.visit(node);
        node = node.getNextSibling();
    }
    // <raises_expr>
    if (node != null && node.getType() == IDLTokenTypes.LITERAL_raises) {
        node = node.getFirstChild();
        while (node != null) {
            // 
            ScopedNameVisitor visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
            visitor.setExceptionMode(true);
            visitor.visit(node);
            CorbaTypeImpl corbaType = visitor.getCorbaType();
            XmlSchemaType schemaType = visitor.getSchemaType();
            // REVISIT, schema type ends with Type for exceptions, so strip it to get the element name.
            int pos = schemaType.getQName().getLocalPart().indexOf("Type");
            QName elementQName = new QName(schemaType.getQName().getNamespaceURI(), schemaType.getQName().getLocalPart().substring(0, pos));
            createFaultMessage(corbaType, operation, bindingOperation, elementQName);
            node = node.getNextSibling();
            visitor.setExceptionMode(false);
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 38 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class PortTypeVisitor method visitInterfaceInheritanceSpec.

private AST visitInterfaceInheritanceSpec(AST interfaceInheritanceSpecNode, Binding binding, Scope childScope) {
    // <interface_inheritance_spec> ::= ":" <interface_name> { "," <interface_name> }*
    AST interfaceNameNode = interfaceInheritanceSpecNode.getFirstChild();
    BindingType corbaBinding = findCorbaBinding(binding);
    List<Scope> inheritedScopes = new ArrayList<>();
    while (interfaceNameNode != null) {
        // check for porttypes in current & parent scopes
        Scope interfaceScope = null;
        PortType intf = null;
        if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
            interfaceScope = ScopedNameVisitor.getFullyScopedName(new Scope(), interfaceNameNode);
            intf = findPortType(interfaceScope);
        }
        Scope currentScope = getScope();
        while (intf == null && currentScope != currentScope.getParent()) {
            if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
                interfaceScope = ScopedNameVisitor.getFullyScopedName(currentScope, interfaceNameNode);
            } else {
                interfaceScope = new Scope(currentScope, interfaceNameNode.toString());
            }
            intf = findPortType(interfaceScope);
            currentScope = currentScope.getParent();
        }
        if (intf == null) {
            if (ScopedNameVisitor.isFullyScopedName(interfaceNameNode)) {
                interfaceScope = ScopedNameVisitor.getFullyScopedName(new Scope(), interfaceNameNode);
            } else {
                interfaceScope = new Scope(new Scope(), interfaceNameNode);
            }
            intf = findPortType(interfaceScope);
        }
        if (intf == null) {
            throw new RuntimeException("[InterfaceVisitor] Unknown Interface: " + interfaceNameNode.toString());
        }
        Scope defnScope = interfaceScope.getParent();
        Definition defn = manager.getWSDLDefinition(mapper.map(defnScope));
        inheritedScopes.add(interfaceScope);
        if (defn != null && !defn.getTargetNamespace().equals(definition.getTargetNamespace())) {
            String key = defnScope.toString("_");
            String fileName = getWsdlVisitor().getOutputDir() + System.getProperty("file.separator") + key;
            manager.addWSDLDefinitionImport(definition, defn, key, fileName);
        }
        Binding inheritedBinding = findBinding(intf);
        BindingType inheritedCorbaBinding = findCorbaBinding(inheritedBinding);
        corbaBinding.getBases().add(inheritedCorbaBinding.getRepositoryID());
        // add all the operations of the inherited port type.
        for (Operation op : CastUtils.cast(intf.getOperations(), Operation.class)) {
            // check to see all the inherited namespaces are added.
            String inputNS = op.getInput().getMessage().getQName().getNamespaceURI();
            manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(inputNS), inputNS);
            // Make sure we import the wsdl for the input namespace
            if (definition.getImports().get(inputNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(inputNS)) {
                manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(inputNS), mapper.mapNSToPrefix(inputNS), manager.getImportedWSDLDefinitionFile(inputNS));
            }
            if (op.getOutput() != null) {
                String outputNS = op.getOutput().getMessage().getQName().getNamespaceURI();
                manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(outputNS), outputNS);
                // Make sure we import the wsdl for the output namespace
                if (definition.getImports().get(outputNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(outputNS)) {
                    manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(outputNS), mapper.mapNSToPrefix(outputNS), manager.getImportedWSDLDefinitionFile(outputNS));
                }
            }
            for (Iterator<Fault> faults = CastUtils.cast(op.getFaults().values().iterator()); faults.hasNext(); ) {
                String faultNS = faults.next().getMessage().getQName().getNamespaceURI();
                manager.addWSDLDefinitionNamespace(definition, mapper.mapNSToPrefix(faultNS), faultNS);
                // Make sure we import the wsdl for the fault namespace
                if (definition.getImports().get(faultNS) == null && !mapper.isDefaultMapping() && !definition.getTargetNamespace().equals(faultNS)) {
                    manager.addWSDLDefinitionImport(definition, manager.getWSDLDefinition(faultNS), mapper.mapNSToPrefix(faultNS), manager.getImportedWSDLDefinitionFile(faultNS));
                }
            }
            portType.addOperation(op);
        }
        // add all the binding extensions of the inherited corba binding
        for (Iterator<BindingOperation> it = CastUtils.cast(inheritedBinding.getBindingOperations().iterator()); it.hasNext(); ) {
            binding.addBindingOperation(it.next());
        }
        interfaceNameNode = interfaceNameNode.getNextSibling();
    }
    if ((!inheritedScopes.isEmpty()) && (wsdlVisitor.getInheritedScopeMap() != null)) {
        wsdlVisitor.getInheritedScopeMap().put(childScope, inheritedScopes);
    }
    return interfaceInheritanceSpecNode.getNextSibling();
}
Also used : Binding(javax.wsdl.Binding) AST(antlr.collections.AST) ArrayList(java.util.ArrayList) Definition(javax.wsdl.Definition) Fault(javax.wsdl.Fault) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) BindingOperation(javax.wsdl.BindingOperation) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) PortType(javax.wsdl.PortType)

Example 39 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class JAXWSDefinitionBuilder method isRPCEncoded.

private boolean isRPCEncoded(Definition def) {
    Iterator<?> ite1 = def.getBindings().values().iterator();
    while (ite1.hasNext()) {
        Binding binding = (Binding) ite1.next();
        String bindingStyle = SOAPBindingUtil.getBindingStyle(binding);
        Iterator<?> ite2 = binding.getBindingOperations().iterator();
        while (ite2.hasNext()) {
            BindingOperation bop = (BindingOperation) ite2.next();
            String bopStyle = SOAPBindingUtil.getSOAPOperationStyle(bop);
            String outputUse = "";
            if (SOAPBindingUtil.getBindingOutputSOAPBody(bop) != null) {
                outputUse = SOAPBindingUtil.getBindingOutputSOAPBody(bop).getUse();
            }
            String inputUse = "";
            if (SOAPBindingUtil.getBindingInputSOAPBody(bop) != null) {
                inputUse = SOAPBindingUtil.getBindingInputSOAPBody(bop).getUse();
            }
            if ((SOAPBinding.Style.RPC.name().equalsIgnoreCase(bindingStyle) || SOAPBinding.Style.RPC.name().equalsIgnoreCase(bopStyle)) && (SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(inputUse) || SOAPBinding.Use.ENCODED.name().equalsIgnoreCase(outputUse))) {
                return true;
            }
        }
    }
    return false;
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation)

Example 40 with BindingOperation

use of javax.wsdl.BindingOperation in project cxf by apache.

the class WSDLToSoapProcessor method addBindingOperation.

@SuppressWarnings("unchecked")
private void addBindingOperation() throws ToolException {
    /**
     * This method won't do unique operation name checking on portType The
     * WS-I Basic Profile[17] R2304 requires that operations within a
     * wsdl:portType have unique values for their name attribute so mapping
     * of WS-I compliant WSDLdescriptions will not generate Java interfaces
     * with overloaded methods. However, for backwards compatibility, JAX-WS
     * supports operation name overloading provided the overloading does not
     * cause conflicts (as specified in the Java Language Specification[25])
     * in the mapped Java service endpoint interface declaration.
     */
    List<Operation> ops = portType.getOperations();
    for (Operation op : ops) {
        BindingOperation bindingOperation = wsdlDefinition.createBindingOperation();
        setSoapOperationExtElement(bindingOperation);
        bindingOperation.setName(op.getName());
        if (op.getInput() != null) {
            bindingOperation.setBindingInput(getBindingInput(op.getInput()));
        }
        if (op.getOutput() != null) {
            bindingOperation.setBindingOutput(getBindingOutput(op.getOutput()));
        }
        if (op.getFaults() != null && op.getFaults().size() > 0) {
            addSoapFaults(op, bindingOperation);
        }
        bindingOperation.setOperation(op);
        binding.addBindingOperation(bindingOperation);
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) Operation(javax.wsdl.Operation) SoapOperation(org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation) BindingOperation(javax.wsdl.BindingOperation)

Aggregations

BindingOperation (javax.wsdl.BindingOperation)54 Binding (javax.wsdl.Binding)25 QName (javax.xml.namespace.QName)20 Operation (javax.wsdl.Operation)16 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)13 BindingInput (javax.wsdl.BindingInput)12 Test (org.junit.Test)12 File (java.io.File)9 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)9 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)9 Definition (javax.wsdl.Definition)8 Message (javax.wsdl.Message)8 BindingFault (javax.wsdl.BindingFault)7 Port (javax.wsdl.Port)7 Service (javax.wsdl.Service)7 SoapOperation (org.apache.cxf.binding.soap.wsdl.extensions.SoapOperation)7 ToolException (org.apache.cxf.tools.common.ToolException)7 Input (javax.wsdl.Input)6 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)6 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)6