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