Package org.apache.tuscany.sca.binding.ws

Examples of org.apache.tuscany.sca.binding.ws.WebServiceBinding


        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should create component service $promoted$Service1 on innermost component
            //  ComponentD, with <binding.ws> and uri="/Service1"
            // No other services on ComponentD should have <binding.ws>
            WebServiceBinding wsBinding = null;
            for (ComponentService service : componentD.getServices()) {
                WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
                if ("$promoted$Service1".equals(service.getName())) {
                    wsBinding = wsb;
                } else {
                    assert wsb == null;
                }
            }
            assert "/Service1".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/$promoted$Service1 with endpoint uri="/Service1"
            Definition def = wsBinding.getWSDLDocument();
            javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
            Port port = svc.getPort("Service3Port");
            assert "/Service1".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not create component service $promoted$Service1 on innermost component ComponentD
            // No component services on ComponentD should have <binding.ws>
            for (ComponentService service : componentD.getServices()) {
                assert !"$promoted$Service1".equals(service.getName());
                assert service.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        for (ComponentService service : componentB.getServices()) {
            assert service.getBinding(WebServiceBinding.class) == null;
        }

        // No services on CompositeC should have <binding.ws>
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario1", "CompositeC"));
        for (Service service : compositeC.getServices()) {
            assert service.getBinding(WebServiceBinding.class) == null;
        }

        if (nonWiring) {
            // Should not add a WSDL document to domain composite service Service1
            WebServiceBinding wsBinding = null;
            for (Service service : domainComposite.getServices()) {
                if ("Service1".equals(service.getName())) {
                    wsBinding = service.getBinding(WebServiceBinding.class);
                }
            }
            assert wsBinding.getWSDLDocument() == null;
        }
    }
View Full Code Here


        Composite domainComposite = customBuilder.getDomainComposite();

        // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
        // No other services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
        for (ComponentService service : componentB.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
            }
View Full Code Here

    private void checkScenario4Results(boolean nonWiring) {
        Composite domainComposite = customBuilder.getDomainComposite();

        // Should create WSDL document for ComponentD/Service3 with endpoint uri="/ComponentD/Service3"
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        WebServiceBinding wsBinding = null;
        for (ComponentService service : componentD.getServices()) {
            if ("Service3".equals(service.getName())) {
                wsBinding = service.getBinding(WebServiceBinding.class);
            }
        }
        Definition def = wsBinding.getWSDLDocument();
        javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
        Port port = svc.getPort("Service3Port");
        assert "/ComponentB/ComponentD/Service3".equals(TestUtils.getPortAddress(port));

        // Should add <binding.ws> to inner composite service CompositeC/Service2
        // No other services on CompositeC should have <binding.ws>
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario4", "CompositeC"));
        wsBinding = null;
        for (Service service : compositeC.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
            }
        }
        assert "/ComponentB/Service2".equals(wsBinding.getURI());

        // Should add <binding.ws> to outer component service ComponentB/Service2
        // Should create WSDL document for ComponentB/Service2 with endpoint uri="/ComponentB/Service2"
        // No other services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        wsBinding = null;
        for (ComponentService service : componentB.getServices()) {
            WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
            if ("Service2".equals(service.getName())) {
                wsBinding = wsb;
            } else {
                assert wsb == null;
            }
View Full Code Here

        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        WebServiceBinding wsBinding;
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
            // Should set <interface.wsdl> on inner component reference ComponentD/reference3
            wsBinding = null;
            for (ComponentReference reference : componentD.getReferences()) {
                if ("reference3".equals(reference.getName())) {
                    wsBinding = reference.getBinding(WebServiceBinding.class);
                    assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
                }
            }
            assert "http://foo.com/bar".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not add <binding.ws> to any inner component references
View Full Code Here

        //  CompositeC/reference2 (for Scenario 7), and add uri="http://foo.com/bar"
        //  to the <binding.ws> element on ComponentB/reference2
        // For nonWiring, ComponentB/reference2 should have target=
        //  and no uri= should be added
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentB.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentB/reference2 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should add <binding.ws> to inner component reference ComponentD/reference3 with uri="http://foo.com/bar"
            // Should set <interface.wsdl> on inner component reference ComponentD/reference3
            wsBinding = null;
            for (ComponentReference reference : componentD.getReferences()) {
                if ("reference3".equals(reference.getName())) {
                    wsBinding = reference.getBinding(WebServiceBinding.class);
                    assert reference.getBindings().size() == 1;
                    assert reference.getInterfaceContract(wsBinding) instanceof WSDLInterfaceContract;
                }
            }
            assert "http://foo.com/bar".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentB/reference2", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not add <binding.ws> to any inner component references
            for (ComponentReference reference : componentD.getReferences()) {
                assert reference.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No references on CompositeC should have <binding.ws> or <interface.wsdl>, except for
        //  reference2 in Scenario 7
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName(namespace, "CompositeC"));
        for (Reference reference : compositeC.getReferences()) {
            if ("http://scenario7".equals(namespace) && "reference2".equals(reference.getName())) {
                assert reference.getBinding(WebServiceBinding.class)!= null;
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            } else {
                assert reference.getBinding(WebServiceBinding.class) == null;
                assert reference.getInterfaceContract() instanceof JavaInterfaceContract;
            }
        }

        // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
        wsBinding = null;
        for (Reference reference : domainComposite.getReferences()) {
            if ("reference1".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
        assert wsBinding.getURI() == null;

        // Should not add a WSDL document to domain composite reference reference1
        assert wsBinding.getWSDLDocument() == null;
    }
View Full Code Here

        Composite domainComposite = customBuilder.getDomainComposite();

        // Should replace target= on ComponentD/reference3 by uri="http://foo.com/bar" on <binding.ws>
        // For nonWiring, the original target= is preserved and there is no uri=
        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        WebServiceBinding wsBinding = null;
        for (ComponentReference reference : componentD.getReferences()) {
            if ("reference3".equals(reference.getName())) {
                if (!nonWiring) {
                    assert reference.getTargets().size() == 0;
                } else {
                    assert reference.getTargets().size() == 1;
                }
                wsBinding = reference.getBinding(WebServiceBinding.class);
            }
        }
        if (!nonWiring) {
            assert "http://foo.com/bar".equals(wsBinding.getURI());
        } else {
            assert wsBinding.getURI() == null;
        }

        Definition def;
        javax.wsdl.Service svc;
        Port port;
        if (!nonWiring) {
            // Should create WSDL document for ComponentD/reference3 with endpoint uri="http://foo.com/bar"
            def = wsBinding.getWSDLDocument();
            svc = def.getService(new QName("http://scenarios/ComponentD/reference3", "Service3aService"));
            port = svc.getPort("Service3aPort");
            assert "http://foo.com/bar".equals(TestUtils.getPortAddress(port));
        }

        // Should add <binding.ws> and <interface.wsdl> to inner composite reference CompositeC/reference2
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario8", "CompositeC"));
        wsBinding = null;
        for (Reference reference : compositeC.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
        assert wsBinding.getURI() == null;

        // Should add <binding.ws> and <interface.wsdl> to outer component reference ComponentB/reference2
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        wsBinding = null;
        for (ComponentReference reference : componentB.getReferences()) {
            if ("reference2".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
        assert wsBinding.getURI() == null;

        // Should add <binding.ws> and <interface.wsdl> to outer composite reference CompositeA/reference1
        wsBinding = null;
        for (Reference reference : domainComposite.getReferences()) {
            if ("reference1".equals(reference.getName())) {
                wsBinding = reference.getBinding(WebServiceBinding.class);
                assert reference.getInterfaceContract() instanceof WSDLInterfaceContract;
            }
        }
        assert wsBinding.getURI() == null;

        // Should not add a WSDL document to domain composite reference reference1
        assert wsBinding.getWSDLDocument() == null;
    }
View Full Code Here

    }

    public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException {

        // Read a <binding.ws>
        WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
        /*IntentAttachPointType bindingType = intentAttachPointTypeFactory.createBindingType();
        bindingType.setName(getArtifactType());
        bindingType.setUnresolved(true);
        ((PolicySetAttachPoint)wsBinding).setType(bindingType);*/
        wsBinding.setUnresolved(true);
        wsBinding.setBuilder(new BindingBuilderImpl(extensionPoints));

        // Read policies
        policyProcessor.readPolicies(wsBinding, reader);

        // Read the binding name
        String name = reader.getAttributeValue(null, NAME);
        if (name != null) {
            wsBinding.setName(name);
        }

        // Read URI
        String uri = reader.getAttributeValue(null, URI);
        if (uri != null) {
            wsBinding.setURI(uri);
        }

        // Read a qname in the form:
        // namespace#wsdl.???(name)
        Boolean wsdlElementIsBinding = null;
        String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT);
        if (wsdlElement != null) {
            int index = wsdlElement.indexOf('#');
            if (index == -1) {
              error("InvalidWsdlElementAttr", reader, wsdlElement);
                //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
              return wsBinding;
            }
            String namespace = wsdlElement.substring(0, index);
            wsBinding.setNamespace(namespace);
            String localName = wsdlElement.substring(index + 1);
            if (localName.startsWith("wsdl.service")) {

                // Read a wsdl.service
                localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
                wsBinding.setServiceName(new QName(namespace, localName));

            } else if (localName.startsWith("wsdl.port")) {

                // Read a wsdl.port
                localName = localName.substring("wsdl.port(".length(), localName.length() - 1);
                int s = localName.indexOf('/');
                if (s == -1) {
                  error("InvalidWsdlElementAttr", reader, wsdlElement);
                    //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                } else {
                    wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                    wsBinding.setPortName(localName.substring(s + 1));
                }
            } else if (localName.startsWith("wsdl.endpoint")) {

                // Read a wsdl.endpoint
                localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1);
                int s = localName.indexOf('/');
                if (s == -1) {
                  error("InvalidWsdlElementAttr", reader, wsdlElement);
                    //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                } else {
                    wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                    wsBinding.setEndpointName(localName.substring(s + 1));
                }
            } else if (localName.startsWith("wsdl.binding")) {

                // Read a wsdl.binding
                localName = localName.substring("wsdl.binding(".length(), localName.length() - 1);
                wsBinding.setBindingName(new QName(namespace, localName));

                wsdlElementIsBinding = true;

            } else {
              error("InvalidWsdlElementAttr", reader, wsdlElement);
                //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
            }
        }

        // Read wsdlLocation
        wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));

        ConfiguredOperation confOp = null;
        // Skip to end element
        while (reader.hasNext()) {
            int event = reader.next();
            switch (event) {
                case START_ELEMENT: {
                    if (END_POINT_REFERENCE.equals(reader.getName().getLocalPart())) {
                        if (wsdlElement != null && (wsdlElementIsBinding == null || !wsdlElementIsBinding)) {
                          error("MustUseWsdlBinding", reader, wsdlElement);
                            throw new ContributionReadException(wsdlElement + " must use wsdl.binding when using wsa:EndpointReference");
                        }
                        wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
                    } else if (Constants.OPERATION_QNAME.equals(reader.getName())) {
                        confOp = configuredOperationProcessor.read(reader);
                        if (confOp != null) {
                            ((OperationsConfigurator)wsBinding).getConfiguredOperations().add(confOp);
                        }
View Full Code Here

        // Set to use the Axiom data binding
        contract.getInterface().setDefaultDataBinding(OMElement.class.getName());

        // look for a matching callback binding
        WebServiceBinding callbackBinding = null;
        if (reference.getCallback() != null) {
            for (Binding binding : reference.getCallback().getBindings()) {
                if (binding instanceof WebServiceBinding) {
                    // set the first compatible callback binding
                    callbackBinding = (WebServiceBinding)binding;
View Full Code Here

    public WebServiceBinding read(XMLStreamReader reader) throws ContributionReadException {
        try {

            // Read a <binding.ws>
            WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
            wsBinding.setUnresolved(true);

            // Read policies
            if ( wsBinding instanceof PolicySetAttachPoint ) {
                readPolicies((PolicySetAttachPoint)wsBinding, reader);
            }
           
            // Read the binding name
            String name = reader.getAttributeValue(null, NAME);
            if (name != null) {
                wsBinding.setName(name);
            }

            // Read URI
            String uri = reader.getAttributeValue(null, URI);
            if (uri != null) {
                wsBinding.setURI(uri);
            }

            // Read a qname in the form:
            // namespace#wsdl.???(name)
            String wsdlElement = reader.getAttributeValue(null, WSDL_ELEMENT);
            if (wsdlElement != null) {
                int index = wsdlElement.indexOf('#');
                if (index == -1) {
                    throw new ContributionReadException(
                                                        "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                }
                String namespace = wsdlElement.substring(0, index);
                wsBinding.setNamespace(namespace);
                String localName = wsdlElement.substring(index + 1);
                if (localName.startsWith("wsdl.service")) {

                    // Read a wsdl.service
                    localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
                    wsBinding.setServiceName(new QName(namespace, localName));

                } else if (localName.startsWith("wsdl.port")) {

                    // Read a wsdl.port
                    localName = localName.substring("wsdl.port(".length(), localName.length() - 1);
                    int s = localName.indexOf('/');
                    if (s == -1) {
                        throw new ContributionReadException(
                                                            "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                    }
                    wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                    wsBinding.setPortName(localName.substring(s + 1));

                } else if (localName.startsWith("wsdl.endpoint")) {

                    // Read a wsdl.endpoint
                    localName = localName.substring("wsdl.endpoint(".length(), localName.length() - 1);
                    int s = localName.indexOf('/');
                    if (s == -1) {
                        throw new ContributionReadException(
                                                            "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                    }
                    wsBinding.setServiceName(new QName(namespace, localName.substring(0, s)));
                    wsBinding.setEndpointName(localName.substring(s + 1));

                } else if (localName.startsWith("wsdl.binding")) {

                    // Read a wsdl.service
                    localName = localName.substring("wsdl.binding(".length(), localName.length() - 1);
                    wsBinding.setBindingName(new QName(namespace, localName));

                } else {
                    throw new ContributionReadException(
                                                        "Invalid WebService binding wsdlElement attribute: " + wsdlElement);
                }
            }

            // Read wsdlLocation
            wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));

            // Skip to end element
            while (reader.hasNext()) {
                if (reader.next() == END_ELEMENT && BINDING_WS_QNAME.equals(reader.getName())) {
                    break;
View Full Code Here

        Component componentD = TestUtils.getComponent(domainComposite, "ComponentD");
        if (!nonWiring) {
            // Should create component service $promoted$Service1 on innermost component
            //  ComponentD, with <binding.ws> and uri="/Service1"
            // No other services on ComponentD should have <binding.ws>
            WebServiceBinding wsBinding = null;
            for (ComponentService service : componentD.getServices()) {
                WebServiceBinding wsb = service.getBinding(WebServiceBinding.class);
                if ("$promoted$Service1".equals(service.getName())) {
                    wsBinding = wsb;
                } else {
                    assert wsb == null;
                }
            }
            assert "/Service1".equals(wsBinding.getURI());

            // Should create WSDL document for ComponentD/$promoted$Service1 with endpoint uri="/Service1"
            Definition def = wsBinding.getWSDLDocument();
            javax.wsdl.Service svc = def.getService(new QName("http://builder.itest.sca.tuscany.apache.org/", "Service3Service"));
            Port port = svc.getPort("Service3Port");
            assert "/Service1".equals(TestUtils.getPortAddress(port));
        } else {
            // Should not create component service $promoted$Service1 on innermost component ComponentD
            // No component services on ComponentD should have <binding.ws>
            for (ComponentService service : componentD.getServices()) {
                assert !"$promoted$Service1".equals(service.getName());
                assert service.getBinding(WebServiceBinding.class) == null;
            }
        }

        // No services on ComponentB should have <binding.ws>
        Component componentB = TestUtils.getComponent(domainComposite, "ComponentB");
        for (ComponentService service : componentB.getServices()) {
            assert service.getBinding(WebServiceBinding.class) == null;
        }

        // No services on CompositeC should have <binding.ws>
        Composite compositeC = TestUtils.getComposite(domainComposite, new QName("http://scenario1", "CompositeC"));
        for (Service service : compositeC.getServices()) {
            assert service.getBinding(WebServiceBinding.class) == null;
        }

        if (nonWiring) {
            // Should not add a WSDL document to domain composite service Service1
            WebServiceBinding wsBinding = null;
            for (Service service : domainComposite.getServices()) {
                if ("Service1".equals(service.getName())) {
                    wsBinding = service.getBinding(WebServiceBinding.class);
                }
            }
            assert wsBinding.getWSDLDocument() == null;
        }
       
        String expectedEndpoints =  "Component - ComponentB\n" +
                                    "Service - Service2\n" +
                                    "Endpoint - Service2\n" +
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.ws.WebServiceBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.