Examples of WebServiceBinding


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

                         System.out.println("Processing: "
                                            component.getName() +
                                            "/" +
                                            service.getName());
                         if (binding instanceof WebServiceBinding){
                             WebServiceBinding bindingWS = (WebServiceBinding) binding;
                             String filename = outputPath +
                                               "/" +
                                               component.getName() +
                                               "_" +
                                               service.getName() +
                                               "_" +
                                               binding.getName() +
                                               ".wsdl";
                             try {
                                 System.out.println("  Writing file: " + filename);
                                 System.out.flush();
                                 File file = new File(filename);
                                 file.createNewFile();
                                 FileOutputStream stream = new FileOutputStream(file);
                                 System.out.println("Generated WSDL for " + component.getName() + "/" + service.getName());
                                 WSDLWriter writer =  javax.wsdl.factory.WSDLFactory.newInstance().newWSDLWriter();
                                 writer.writeWSDL(bindingWS.getWSDLDefinition().getDefinition(),stream);
                             } catch (Exception e) {
                                 throw new WSDLGenerationException(e);
                             }
                         } else {
                             System.out.println("  No binding.ws" );
View Full Code Here

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

    }

    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));
       
        // Handle extended attributes
        for (int a = 0; a < reader.getAttributeCount(); a++) {
            QName attributeName = reader.getAttributeName(a);
            if( attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI() != WSDLI_NS && attributeName.getNamespaceURI().length() > 0) {
                if( (! Constants.SCA10_NS.equals(attributeName.getNamespaceURI()) &&
                    (! Constants.SCA10_TUSCANY_NS.equals(attributeName.getNamespaceURI()) ))) {
                    Object attributeValue = extensionAttributeProcessor.read(attributeName, reader);
                    Extension attributeExtension;
                    if (attributeValue instanceof Extension) {
                        attributeExtension = (Extension) attributeValue;
                    } else {
                        attributeExtension = extensionFactory.createExtension(attributeName, attributeValue, true);
                    }
                    wsBinding.getAttributeExtensions().add(attributeExtension);
                }
            }
        }


        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

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

            from.setTargetEndpoint(fromEndpoint);
            from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
            msg.setFrom(from);
            RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
            //
            WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
            cbBinding.setURI(callbackAddress);
            callbackEndpoint.setBinding(cbBinding);
            //
            callbackEndpoint.setURI(callbackAddress);
            callbackEndpoint.setUnresolved(true);
            from.setCallbackEndpoint(callbackEndpoint);
View Full Code Here

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

        policySubject.getRequiredIntents().add(soapIntent);
    }
   
    private void createWSBinding(JavaImplementation javaImplementation, Service service){
        if(service.getBindings().size() == 0){
            WebServiceBinding wsBinding = wsBindingFactory.createWebServiceBinding();
            wsBinding.setName(service.getName());
            ExtensionType bindingType = policyFactory.createBindingType();
            bindingType.setType(WebServiceConstants.BINDING_WS_QNAME);
            bindingType.setUnresolved(true);
            ((PolicySubject)wsBinding).setExtensionType(bindingType);
            service.getBindings().add(wsBinding);
View Full Code Here

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

                from.setTargetEndpoint(fromEndpoint);
                from.setStatus(EndpointReference.Status.WIRED_TARGET_FOUND_AND_MATCHED);
                requestMsg.setFrom(from);
                RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
                //
                WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
                cbBinding.setURI(callbackAddress);
                callbackEndpoint.setBinding(cbBinding);
                //
                callbackEndpoint.setURI(callbackAddress);
                callbackEndpoint.setUnresolved(true);
                from.setCallbackEndpoint(callbackEndpoint);
View Full Code Here

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

       
        // Test that generated WSDL matches expected
        // 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

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

    }   

    public WebServiceBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
        Monitor monitor = context.getMonitor();
        // Read a <binding.ws>
        WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
        /*ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
        bindingType.setName(getArtifactType());
        bindingType.setUnresolved(true);
        ((PolicySubject)wsBinding).setType(bindingType);*/
        wsBinding.setUnresolved(true);

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

        // Read the binding name
        String name = reader.getAttributeValue(null, NAME);
        if (name != null) {
            wsBinding.setName(name);
        }
       
        // a collection of endpoint specifications so that we can test that
        // only one is present
        List<String> endpointSpecifications = new ArrayList<String>();

        // Read URI
        String uri = getURIString(reader, URI);
        if (uri != null) {
            wsBinding.setURI(uri);
            wsBinding.setUserSpecifiedURI(uri);
           
            // BWS20001
            if (context.getParentModel() instanceof Reference){
                try {
                    URI tmpURI = new URI(uri);
                   
                    if (!tmpURI.isAbsolute()){
                        error(monitor, "URINotAbsolute", reader, uri);
                    }
                } catch (URISyntaxException ex){
                    error(monitor, "InvalidURISyntax", reader, ex.getMessage());
                }
                endpointSpecifications.add("uri");
            }
           
            // BWS20020
            if ((context.getParentModel() instanceof Callback) &&
                (((Callback)context.getParentModel()).getParentContract() instanceof org.apache.tuscany.sca.assembly.Service)){
                error(monitor, "URIFoundForServiceCallback", reader, uri);
            }
        }

        // Read a qname in the form:
        // namespace#wsdl.???(name)
        Boolean wsdlElementIsBinding = null;
        String wsdlElement = getURIString(reader, WSDL_ELEMENT);
        if (wsdlElement != null) {
            int index = wsdlElement.indexOf('#');
            if (index == -1) {
              error(monitor, "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")) {

                // BWS20003
                if (context.getParentModel() instanceof org.apache.tuscany.sca.assembly.Service){
                    error(monitor, "WSDLServiceOnService", reader, wsdlElement);
                }
               
                // Read a wsdl.service
                localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
                wsBinding.setServiceName(new QName(namespace, localName));
               
                endpointSpecifications.add("#wsdl.service");

            } 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(monitor, "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));
                }
               
                endpointSpecifications.add("#wsdl.port");
            } 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(monitor, "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(monitor, "InvalidWsdlElementAttr", reader, wsdlElement);
                //throw new ContributionReadException("Invalid WebService binding wsdlElement attribute: " + wsdlElement);
            }
        }

        // Read wsdlLocation
        String wsdliLocation = reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION);
        if (wsdliLocation != null) {
            if (wsdlElement == null) {
                error(monitor, "WsdliLocationMissingWsdlElement", reader);
            }
            String[] iris = wsdliLocation.split(" ");
            if (iris.length % 2 != 0) {
                error(monitor, "WsdliLocationNotIRIPairs", reader);
            }
            for (int i=0; i<iris.length-1; i=i+2) {
                wsBinding.getWsdliLocations().put(iris[i], iris[i+1]);
            }
        }

        //add binding extensions
        QName elementName = reader.getName();
        for (int i = 0; i < reader.getAttributeCount(); i++) {
            QName attributeName = reader.getAttributeName(i);
            if(attributeName.getNamespaceURI() != null && attributeName.getNamespaceURI().length() > 0 && !(attributeName.getNamespaceURI().equals(WSDLI_NS))) {               
                if(!elementName.getNamespaceURI().equals(attributeName.getNamespaceURI()) ) {
                    Object attributeValue = extensionAttributeProcessor.read(attributeName, reader, processorContext);
                    Extension attributeExtension;
                    if (attributeValue instanceof Extension) {
                        attributeExtension = (Extension)attributeValue;
                    } else {
                        attributeExtension = assemblyFactory.createExtension();
                        attributeExtension.setQName(attributeName);
                        attributeExtension.setValue(attributeValue);
                        attributeExtension.setAttribute(true);
                    }
                    ((Extensible)wsBinding).getAttributeExtensions().add(attributeExtension);
                }
            }
        }
        // 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(monitor, "MustUseWsdlBinding", reader, wsdlElement);
                            String message = context.getMonitor().getMessageString(WebServiceBindingProcessor.class.getName(),
                                                                                   "binding-wsxml-validation-messages",
                                                                                   "MustUseWsdlBinding");
                            message = message.replace("{0}", wsdlElement);
                            throw new ContributionReadException(message);
                        }
                       
                        wsBinding.setEndPointReference(EndPointReferenceHelper.readEndPointReference(reader));
                        endpointSpecifications.add("wsa:EndpointReference");
                    }
                }
                    break;

View Full Code Here

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

        WebServiceBindingFactory webServiceBindingFactory = (WebServiceBindingFactory)modelFactories.getFactory(WebServiceBindingFactory.class);
   
        // Create the endpoint
        RuntimeEndpoint callbackEndpoint = (RuntimeEndpoint)assemblyFactory.createEndpoint();
        // Add a binding
        WebServiceBinding cbBinding = webServiceBindingFactory.createWebServiceBinding();
        cbBinding.setURI(callbackAddress);
        callbackEndpoint.setBinding(cbBinding);
        // Embed the response Address URI
        callbackEndpoint.setURI(callbackAddress);
        callbackEndpoint.setUnresolved(true);
    return callbackEndpoint;
View Full Code Here

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

        // xml messages that will be sent

        // I think we have to check for asIs because the Java2WSDL will blow up when using javax.jms.Message
        if (service.getInterfaceContract() != null && !isAsIs()) {
            WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
            WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
            BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), service, wsBinding, registry, null);
            interfaceContract = wsBinding.getBindingInterfaceContract();
            interfaceContract.getInterface().resetDataBinding(XMLHelperFactory.createXMLHelper(registry).getDataBindingName());

            List<Operation> wsdlOpList = interfaceContract.getInterface().getOperations();

            for (Operation op : opList) {
View Full Code Here

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

        // deal with the data format that this wire format is expecting to send to
        // and receive from the databinding interceptor. The request/response parts of
        // this interface contract will be copied into the binding interface contract
        // as required
        WebServiceBindingFactory wsFactory = registry.getExtensionPoint(WebServiceBindingFactory.class);
        WebServiceBinding wsBinding = wsFactory.createWebServiceBinding();
        BindingWSDLGenerator.generateWSDL(endpoint.getComponent(), endpoint.getService(), wsBinding, registry, null);
        interfaceContract = wsBinding.getBindingInterfaceContract();
        interfaceContract.getInterface().resetDataBinding(XMLHelperFactory.createXMLHelper(registry).getDataBindingName());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.