Search in sources :

Example 46 with BindingOperation

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

the class WSDLRefValidator method collectValidationPointsForBindings.

private void collectValidationPointsForBindings() throws Exception {
    Map<QName, XNode> vBindingNodes = new HashMap<>();
    for (Service service : services.values()) {
        vBindingNodes.putAll(getBindings(service));
    }
    for (Map.Entry<QName, XNode> entry : vBindingNodes.entrySet()) {
        QName bName = entry.getKey();
        Binding binding = this.definition.getBinding(bName);
        if (binding == null) {
            LOG.log(Level.SEVERE, bName.toString() + " is not correct, please check that the correct namespace is being used");
            throw new Exception(bName.toString() + " is not correct, please check that the correct namespace is being used");
        }
        XNode vBindingNode = getXNode(binding);
        vBindingNode.setFailurePoint(entry.getValue());
        vNodes.add(vBindingNode);
        if (binding.getPortType() == null) {
            continue;
        }
        portTypeRefNames.add(binding.getPortType().getQName());
        XNode vPortTypeNode = getXNode(binding.getPortType());
        vPortTypeNode.setFailurePoint(vBindingNode);
        vNodes.add(vPortTypeNode);
        Collection<BindingOperation> bops = CastUtils.cast(binding.getBindingOperations());
        for (BindingOperation bop : bops) {
            XNode vOpNode = getOperationXNode(vPortTypeNode, bop.getName());
            XNode vBopNode = getOperationXNode(vBindingNode, bop.getName());
            vOpNode.setFailurePoint(vBopNode);
            vNodes.add(vOpNode);
            if (bop.getBindingInput() != null) {
                String inName = bop.getBindingInput().getName();
                if (!StringUtils.isEmpty(inName)) {
                    XNode vInputNode = getInputXNode(vOpNode, inName);
                    vInputNode.setFailurePoint(getInputXNode(vBopNode, inName));
                    vNodes.add(vInputNode);
                }
            }
            if (bop.getBindingOutput() != null) {
                String outName = bop.getBindingOutput().getName();
                if (!StringUtils.isEmpty(outName)) {
                    XNode vOutputNode = getOutputXNode(vOpNode, outName);
                    vOutputNode.setFailurePoint(getOutputXNode(vBopNode, outName));
                    vNodes.add(vOutputNode);
                }
            }
            for (Iterator<?> iter1 = bop.getBindingFaults().keySet().iterator(); iter1.hasNext(); ) {
                String faultName = (String) iter1.next();
                XNode vFaultNode = getFaultXNode(vOpNode, faultName);
                vFaultNode.setFailurePoint(getFaultXNode(vBopNode, faultName));
                vNodes.add(vFaultNode);
            }
        }
    }
}
Also used : XBinding(org.apache.cxf.tools.validator.internal.model.XBinding) Binding(javax.wsdl.Binding) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) XNode(org.apache.cxf.tools.validator.internal.model.XNode) Service(javax.wsdl.Service) XService(org.apache.cxf.tools.validator.internal.model.XService) URISyntaxException(java.net.URISyntaxException) ToolException(org.apache.cxf.tools.common.ToolException) BindingOperation(javax.wsdl.BindingOperation) Map(java.util.Map) HashMap(java.util.HashMap)

Example 47 with BindingOperation

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

the class WSIBPValidator method checkBinding.

public boolean checkBinding() {
    for (PortType portType : wsdlHelper.getPortTypes(def)) {
        Iterator<?> ite = portType.getOperations().iterator();
        while (ite.hasNext()) {
            Operation operation = (Operation) ite.next();
            if (isOverloading(operation.getName())) {
                continue;
            }
            BindingOperation bop = wsdlHelper.getBindingOperation(def, operation.getName());
            if (bop == null) {
                addErrorMessage(getErrorPrefix("WSI-BP-1.0 R2718") + "A wsdl:binding in a DESCRIPTION MUST have the same set of " + "wsdl:operations as the wsdl:portType to which it refers. " + operation.getName() + " not found in wsdl:binding.");
                return false;
            }
            Binding binding = wsdlHelper.getBinding(bop, def);
            String bindingStyle = binding != null ? SOAPBindingUtil.getBindingStyle(binding) : "";
            String style = StringUtils.isEmpty(SOAPBindingUtil.getSOAPOperationStyle(bop)) ? bindingStyle : SOAPBindingUtil.getSOAPOperationStyle(bop);
            if ("DOCUMENT".equalsIgnoreCase(style) || StringUtils.isEmpty(style)) {
                boolean passed = checkR2201Input(operation, bop) && checkR2201Output(operation, bop) && checkR2209(operation, bop) && checkR2716(bop);
                if (!passed) {
                    return false;
                }
            } else {
                if (!checkR2717AndR2726(bop)) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : SOAPBinding(javax.jws.soap.SOAPBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) PortType(javax.wsdl.PortType)

Example 48 with BindingOperation

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

the class WSDLToCorbaBindingTest method setTestIdTest.

private void setTestIdTest(Binding binding) {
    BindingOperation bindingOp = binding.getBindingOperation("_set_test_id", "_set_test_id", "_set_test_idResponse");
    assertEquals("_set_test_id", bindingOp.getName());
    assertEquals(1, bindingOp.getExtensibilityElements().size());
    assertEquals(bindingOp.getBindingInput().getName(), "_set_test_id");
    assertEquals(bindingOp.getBindingOutput().getName(), "_set_test_idResponse");
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOp)) {
        if (extElement.getElementType().getLocalPart().equals("operation")) {
            OperationType corbaOpType = (OperationType) extElement;
            assertEquals(corbaOpType.getName(), "_set_test_id");
            assertEquals(1, corbaOpType.getParam().size());
            assertEquals(corbaOpType.getParam().get(0).getName(), "_arg");
            assertEquals(corbaOpType.getParam().get(0).getMode().value(), "in");
            assertEquals(corbaOpType.getParam().get(0).getIdltype(), CorbaConstants.NT_CORBA_FLOAT);
        }
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 49 with BindingOperation

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

the class WSDLToCorbaBindingTest method testVoidTest.

private void testVoidTest(Binding binding) {
    BindingOperation bindingOp = binding.getBindingOperation("test_void", "test_void", "test_voidResponse");
    assertEquals("test_void", bindingOp.getName());
    assertEquals(1, bindingOp.getExtensibilityElements().size());
    assertEquals(bindingOp.getBindingInput().getName(), "test_void");
    assertEquals(bindingOp.getBindingOutput().getName(), "test_voidResponse");
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOp)) {
        if (extElement.getElementType().getLocalPart().equals("operation")) {
            OperationType corbaOpType = (OperationType) extElement;
            assertEquals(corbaOpType.getName(), "test_void");
            assertEquals(0, corbaOpType.getParam().size());
        }
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 50 with BindingOperation

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

the class WSDLToCorbaBindingTest method testCORBABindingGeneration.

@Test
public void testCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/simpleList.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("BasePortType");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("BaseCORBABinding", binding.getQName().getLocalPart());
    assertEquals("BasePortType", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(1, binding.getBindingOperations().size());
    for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
        if (extElement.getElementType().getLocalPart().equals("binding")) {
            BindingType bindingType = (BindingType) extElement;
            assertEquals(bindingType.getRepositoryID(), "IDL:BasePortType:1.0");
        }
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        assertEquals(bindingOperation.getBindingInput().getName(), "echoString");
        assertEquals(bindingOperation.getBindingOutput().getName(), "echoStringResponse");
        for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
            if (extElement.getElementType().getLocalPart().equals("operation")) {
                OperationType corbaOpType = (OperationType) extElement;
                assertEquals(corbaOpType.getName(), "echoString");
                assertEquals(3, corbaOpType.getParam().size());
                assertEquals(corbaOpType.getReturn().getName(), "return");
                assertEquals(corbaOpType.getReturn().getIdltype(), CorbaConstants.NT_CORBA_STRING);
                assertEquals(corbaOpType.getParam().get(0).getName(), "x");
                assertEquals(corbaOpType.getParam().get(0).getMode().value(), "in");
                QName qname = new QName("http://schemas.apache.org/tests/corba/typemap/", "StringEnum1", "ns1");
                assertEquals(corbaOpType.getParam().get(0).getIdltype(), qname);
            }
        }
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

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