Search in sources :

Example 1 with OperationInfo

use of org.talend.designer.webservice.ws.wsdlinfo.OperationInfo in project tdi-studio-se by Talend.

the class WSDLDiscoveryHelper method getFunctionsAvailable.

/**
     * DOC gcui Comment method "getFunctionsAvailable".
     * 
     * @param wsdlURI
     * @return
     */
public List<Function> getFunctionsAvailable(String wsdlURI, ServiceHelperConfiguration config) {
    functionsAvailable = new ArrayList();
    wsdlURI = TalendTextUtils.removeQuotes(wsdlURI);
    try {
        ComponentBuilder builder = new ComponentBuilder();
        ServiceInfo serviceInfo = new ServiceInfo();
        serviceInfo.setWsdlUri(wsdlURI);
        serviceInfo.setAuthConfig(config);
        serviceInfo = builder.buildserviceinformation(serviceInfo);
        if (serviceInfo != null) {
            Iterator iter = serviceInfo.getOperations();
            while (iter.hasNext()) {
                OperationInfo oper = (OperationInfo) iter.next();
                // operationName
                Function f = new Function(oper.getTargetMethodName());
                String operationName = oper.getTargetMethodName() + "(";
                if (serviceInfo.getServerName() != null) {
                    f.setServerName(serviceInfo.getServerName());
                }
                if (serviceInfo.getServerNameSpace() != null) {
                    f.setServerNameSpace(serviceInfo.getServerNameSpace());
                }
                if (serviceInfo.getPortNames() != null) {
                    f.setPortNames(serviceInfo.getPortNames());
                }
                if (oper.getSoapActionURI() != null) {
                    f.setSoapAction(oper.getSoapActionURI());
                }
                if (oper.getNamespaceURI() != null) {
                    f.setNameSpaceURI(oper.getNamespaceURI());
                }
                if (oper.getEncodingStyle() != null) {
                    f.setEncodingStyle(oper.getEncodingStyle());
                }
                if (oper.getTargetURL() != null) {
                    f.setAddressLocation(oper.getTargetURL());
                }
                List inps = oper.getInparameters();
                List outps = oper.getOutparameters();
                // input parameters
                inputParameters = new ArrayList();
                if (inps.size() == 0) {
                    inputParameters.add(new ParameterInfo());
                    operationName = operationName + "):";
                } else if (inps.size() > 0 && inps != null) {
                    for (Iterator iterator1 = inps.iterator(); iterator1.hasNext(); ) {
                        ParameterInfo element = (ParameterInfo) iterator1.next();
                        getParaFullName(element);
                        // ParameterInfo p = new ParameterInfo();
                        // p.setType(element.getKind());
                        inputParameters.add(element);
                        if (element.getType() != null) {
                            operationName = operationName + element.getType() + ",";
                        } else if (element.getType() == null && element.getName() != null) {
                            operationName = operationName + element.getName() + ",";
                        } else if (element.getType() == null) {
                            operationName = operationName + "noType" + ",";
                        }
                        if (element.getType() == null && (element.getParameterInfos() == null || element.getParameterInfos().isEmpty()) && inps.size() == 1) {
                            element.setName(element.getName());
                        }
                    }
                    int operationNamelen = operationName.length();
                    operationName = operationName.substring(0, operationNamelen - 1) + "):";
                    f.setInputParameters(inputParameters);
                }
                // output parameters
                outputParameters = new ArrayList();
                if (outps.size() == 0) {
                    outputParameters.add(new ParameterInfo());
                } else {
                    for (Iterator iterator2 = outps.iterator(); iterator2.hasNext(); ) {
                        ParameterInfo element = (ParameterInfo) iterator2.next();
                        getParaFullName(element);
                        // ParameterInfo p = new ParameterInfo();
                        // p.setType(element.getKind());
                        outputParameters.add(element);
                        if (element.getType() != null) {
                            operationName = operationName + element.getType() + ",";
                        } else if (element.getParameterInfos() != null && !element.getParameterInfos().isEmpty()) {
                            for (Object element2 : element.getParameterInfos()) {
                                ParameterInfo elementBranch = (ParameterInfo) element2;
                                if (elementBranch.getType() != null) {
                                    operationName = operationName + elementBranch.getType() + ",";
                                } else {
                                    operationName = operationName + "noType" + ",";
                                }
                            }
                        }
                    }
                    int operationNamelen = operationName.length();
                    operationName = operationName.substring(0, operationNamelen - 1);
                    f.setOutputParameters(outputParameters);
                }
                f.setName(operationName);
                functionsAvailable.add(f);
            }
        }
    } catch (Exception e) {
        MessageBoxExceptionHandler.process(e);
    }
    return functionsAvailable;
}
Also used : ServiceInfo(org.talend.designer.webservice.ws.wsdlinfo.ServiceInfo) OperationInfo(org.talend.designer.webservice.ws.wsdlinfo.OperationInfo) Function(org.talend.designer.webservice.ws.wsdlinfo.Function) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) ComponentBuilder(org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder)

Example 2 with OperationInfo

use of org.talend.designer.webservice.ws.wsdlinfo.OperationInfo in project tdi-studio-se by Talend.

the class ComponentBuilder method buildOperations.

private List buildOperations(Binding binding) {
    List operationInfos = new ArrayList();
    List operations = binding.getBindingOperations();
    if (operations != null && !operations.isEmpty()) {
        Vector soapBindingElems = findExtensibilityElement(binding.getExtensibilityElements(), "binding");
        // default
        String style = "document";
        ExtensibilityElement soapBindingElem = (ExtensibilityElement) soapBindingElems.elementAt(0);
        if (soapBindingElem != null && soapBindingElem instanceof SOAPBinding) {
            SOAPBinding soapBinding = (SOAPBinding) soapBindingElem;
            style = soapBinding.getStyle();
        } else if (soapBindingElem != null && soapBindingElem instanceof SOAP12Binding) {
            SOAP12Binding soapBinding = (SOAP12Binding) soapBindingElem;
            style = soapBinding.getStyle();
        }
        Iterator opIter = operations.iterator();
        while (opIter.hasNext()) {
            alldExtendtion.clear();
            BindingOperation oper = (BindingOperation) opIter.next();
            Vector operElems = findExtensibilityElement(oper.getExtensibilityElements(), "operation");
            ExtensibilityElement operElem = (ExtensibilityElement) operElems.elementAt(0);
            if (operElem != null && operElem instanceof SOAPOperation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            } else if (operElem != null && operElem instanceof SOAP12Operation) {
                OperationInfo operationInfo = new OperationInfo(style);
                buildOperation(operationInfo, oper);
                operationInfos.add(operationInfo);
            }
        }
    }
    return operationInfos;
}
Also used : OperationInfo(org.talend.designer.webservice.ws.wsdlinfo.OperationInfo) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) List(java.util.List) ArrayList(java.util.ArrayList) Vector(java.util.Vector) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 3 with OperationInfo

use of org.talend.designer.webservice.ws.wsdlinfo.OperationInfo in project tdi-studio-se by Talend.

the class ComponentBuilder method populateComponent.

private ServiceInfo populateComponent(ServiceInfo component, Service service) {
    QName qName = service.getQName();
    String namespace = qName.getNamespaceURI();
    String name = qName.getLocalPart();
    component.setServerName(name);
    component.setServerNameSpace(namespace);
    Map ports = service.getPorts();
    Iterator portIter = ports.values().iterator();
    while (portIter.hasNext()) {
        Port port = (Port) portIter.next();
        Binding binding = port.getBinding();
        if (port.getName() != null && component.getPortNames() == null) {
            List<PortNames> portNames = new ArrayList();
            PortNames portName = new PortNames();
            portName.setPortName(port.getName());
            portNames.add(portName);
            component.setPortNames(portNames);
        } else if (port.getName() != null && component.getPortNames() != null) {
            PortNames portName = new PortNames();
            portName.setPortName(port.getName());
            component.getPortNames().add(portName);
        }
        List operations = buildOperations(binding);
        Iterator operIter = operations.iterator();
        while (operIter.hasNext()) {
            OperationInfo operation = (OperationInfo) operIter.next();
            Vector addrElems = findExtensibilityElement(port.getExtensibilityElements(), "address");
            ExtensibilityElement element = (ExtensibilityElement) addrElems.elementAt(0);
            if (element != null && element instanceof SOAPAddress) {
                SOAPAddress soapAddr = (SOAPAddress) element;
                operation.setTargetURL(soapAddr.getLocationURI());
            } else if (element != null && element instanceof SOAP12Address) {
                SOAP12Address soapAddr = (SOAP12Address) element;
                operation.setTargetURL(soapAddr.getLocationURI());
            }
            component.addOperation(operation);
        }
    }
    return component;
}
Also used : SOAPBinding(javax.wsdl.extensions.soap.SOAPBinding) SOAP12Binding(javax.wsdl.extensions.soap12.SOAP12Binding) Binding(javax.wsdl.Binding) OperationInfo(org.talend.designer.webservice.ws.wsdlinfo.OperationInfo) QName(javax.xml.namespace.QName) Port(javax.wsdl.Port) ArrayList(java.util.ArrayList) UnknownExtensibilityElement(javax.wsdl.extensions.UnknownExtensibilityElement) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) PortNames(org.talend.designer.webservice.ws.wsdlinfo.PortNames) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) Vector(java.util.Vector) SOAP12Address(javax.wsdl.extensions.soap12.SOAP12Address)

Aggregations

ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 OperationInfo (org.talend.designer.webservice.ws.wsdlinfo.OperationInfo)3 Vector (java.util.Vector)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 UnknownExtensibilityElement (javax.wsdl.extensions.UnknownExtensibilityElement)2 SOAPBinding (javax.wsdl.extensions.soap.SOAPBinding)2 SOAP12Binding (javax.wsdl.extensions.soap12.SOAP12Binding)2 Map (java.util.Map)1 Binding (javax.wsdl.Binding)1 BindingOperation (javax.wsdl.BindingOperation)1 Port (javax.wsdl.Port)1 SOAPAddress (javax.wsdl.extensions.soap.SOAPAddress)1 SOAPOperation (javax.wsdl.extensions.soap.SOAPOperation)1 SOAP12Address (javax.wsdl.extensions.soap12.SOAP12Address)1 SOAP12Operation (javax.wsdl.extensions.soap12.SOAP12Operation)1 QName (javax.xml.namespace.QName)1 Function (org.talend.designer.webservice.ws.wsdlinfo.Function)1 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)1