Search in sources :

Example 1 with ComponentBuilder

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

the class AllTypeDialog method init.

private void init() throws Exception {
    labelAndNameSpaceMap.clear();
    URLValue = TalendTextUtils.removeQuotes(URLValue);
    ComponentBuilder builder = new ComponentBuilder();
    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setWsdlUri(URLValue);
    serviceInfo.setAuthConfig(serverConfig);
    serviceInfo = builder.buildserviceinformation(serviceInfo);
    allXmlSchemaType = builder.getAllXmlSchemaType();
    allXmlSchemaElement = builder.getAllXmlSchemaElement();
    initSimpleType();
    initComplexType();
    allXMLSchemaTypeName = new String[allXmlSchemaType.size() + allXMLSimpleTypeName.length];
    for (int i = 0; i < allXMLSimpleTypeName.length; i++) {
        allXMLSchemaTypeName[i] = allXMLSimpleTypeName[i];
    }
    for (int i = allXMLSimpleTypeName.length; i < allXmlSchemaType.size() + allXMLSimpleTypeName.length; i++) {
        allXMLSchemaTypeName[i] = COMPLEXTYPE + allXmlSchemaType.get(i - allXMLSimpleTypeName.length).getName();
    }
}
Also used : ServiceInfo(org.talend.designer.webservice.ws.wsdlinfo.ServiceInfo) ComponentBuilder(org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder)

Example 2 with ComponentBuilder

use of org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder 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 3 with ComponentBuilder

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

the class ComponentBuilderTest method testBuildParameterFromTypes.

@Test
public void testBuildParameterFromTypes() throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, NoSuchMethodException, InvocationTargetException, WSDLException {
    ParameterInfo parameter = new ParameterInfo();
    String name = "parameter";
    String nameSpace = "http://parameter";
    parameter.setName(name);
    parameter.setNameSpace(nameSpace);
    ComponentBuilder cb = new ComponentBuilder();
    Field field = cb.getClass().getDeclaredField("allXmlSchemaType");
    field.setAccessible(true);
    List<XmlSchemaType> allXmlSchemaType = (List<XmlSchemaType>) field.get(cb);
    XmlSchema first = new XmlSchema();
    first.setId("first");
    XmlSchemaSimpleType xsst = new XmlSchemaSimpleType(first);
    xsst.setId("first");
    xsst.setName("first");
    xsst.setSourceURI("http://first");
    XmlSchema two = new XmlSchema();
    two.setId("two");
    two.setTargetNamespace(nameSpace);
    String nameSpaceTwo = "http://parameter";
    XmlSchemaComplexType xsc = new XmlSchemaComplexType(two);
    XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
    xmlSchemaSequence.setId("sequence");
    XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
    xmlSchemaElement.setSourceURI(nameSpaceTwo);
    xmlSchemaElement.setQName(new QName(nameSpaceTwo, "parameter"));
    xmlSchemaElement.setName(name);
    xmlSchemaSequence.getItems().add(xmlSchemaElement);
    xsc.setParticle(xmlSchemaSequence);
    xsc.setId("two");
    xsc.setName("parameter");
    XmlSchemaComplexContent contentModel = new XmlSchemaComplexContent();
    XmlSchemaComplexContentExtension xmlSchemaContent = new XmlSchemaComplexContentExtension();
    xmlSchemaContent.setId("two");
    xmlSchemaContent.setBaseTypeName(new QName(nameSpace, "two"));
    xmlSchemaContent.setSourceURI(nameSpaceTwo);
    contentModel.setSourceURI(nameSpace);
    contentModel.setContent(xmlSchemaContent);
    xsc.setContentModel(contentModel);
    allXmlSchemaType.add(xsst);
    allXmlSchemaType.add(xsc);
    Method m = cb.getClass().getDeclaredMethod("buileParameterFromTypes", new Class[] { String.class, String.class, ParameterInfo.class, int.class });
    m.setAccessible(true);
    m.invoke(cb, nameSpace, name, parameter, 5);
    ParameterInfo parameterInfo = parameter.getParameterInfos().get(0);
    Assert.assertNotNull(parameterInfo);
    Assert.assertEquals(nameSpace, parameterInfo.getNameSpace());
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Method(java.lang.reflect.Method) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaComplexContent(org.apache.ws.commons.schema.XmlSchemaComplexContent) Field(java.lang.reflect.Field) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchema(org.apache.ws.commons.schema.XmlSchema) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) List(java.util.List) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) ComponentBuilder(org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder) Test(org.junit.Test)

Aggregations

ComponentBuilder (org.talend.designer.webservice.ws.wsdlutil.ComponentBuilder)3 List (java.util.List)2 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)2 ServiceInfo (org.talend.designer.webservice.ws.wsdlinfo.ServiceInfo)2 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 QName (javax.xml.namespace.QName)1 XmlSchema (org.apache.ws.commons.schema.XmlSchema)1 XmlSchemaComplexContent (org.apache.ws.commons.schema.XmlSchemaComplexContent)1 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)1 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)1 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1 Test (org.junit.Test)1 Function (org.talend.designer.webservice.ws.wsdlinfo.Function)1 OperationInfo (org.talend.designer.webservice.ws.wsdlinfo.OperationInfo)1