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();
}
}
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;
}
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());
}
Aggregations