use of org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation in project pentaho-kettle by pentaho.
the class WebServiceDialog method loadWebService.
private void loadWebService(String anURI) throws KettleException {
anURI = transMeta.environmentSubstitute(anURI);
try {
if (wProxyHost.getText() != null && !"".equals(wProxyHost.getText())) {
Properties systemProperties = System.getProperties();
systemProperties.setProperty("http.proxyHost", transMeta.environmentSubstitute(wProxyHost.getText()));
systemProperties.setProperty("http.proxyPort", transMeta.environmentSubstitute(wProxyPort.getText()));
}
wsdl = new Wsdl(new URI(anURI), null, null, wHttpLogin.getText(), wHttpPassword.getText());
} catch (Exception e) {
wsdl = null;
new ErrorDialog(shell, BaseMessages.getString(PKG, "WebServiceDialog.ERROR0009.UnreachableURI"), BaseMessages.getString(PKG, "WebServiceDialog.ErrorDialog.Title") + anURI, e);
log.logError(BaseMessages.getString(PKG, "WebServiceDialog.ErrorDialog.Title") + anURI, e.getMessage());
return;
}
String text = wOperation.getText();
wOperation.removeAll();
if (wsdl != null) {
List<WsdlOperation> listeOperations = wsdl.getOperations();
Collections.sort(listeOperations, new Comparator<WsdlOperation>() {
public int compare(WsdlOperation op1, WsdlOperation op2) {
return op1.getOperationQName().getLocalPart().compareTo(op2.getOperationQName().getLocalPart());
}
});
for (Iterator<WsdlOperation> itr = listeOperations.iterator(); itr.hasNext(); ) {
WsdlOperation op = itr.next();
wOperation.add(op.getOperationQName().getLocalPart());
if (op.getOperationQName().getLocalPart().equals(text)) {
wOperation.setText(text);
}
}
}
}
use of org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation in project pentaho-kettle by pentaho.
the class WebServiceDialog method loadOperation.
private void loadOperation(String anOperationName) throws KettleException {
wsdlOperation = null;
inWsdlParamContainer = null;
outWsdlParamContainer = null;
if (wsdl != null) {
for (Iterator<WsdlOperation> vItOperation = wsdl.getOperations().iterator(); vItOperation.hasNext() && wsdlOperation == null; ) {
WsdlOperation vCurrentOperation = vItOperation.next();
if (vCurrentOperation.getOperationQName().getLocalPart().equals(anOperationName)) {
wsdlOperation = vCurrentOperation;
}
}
}
if (wsdlOperation != null) {
// figure out the request name
//
String request = "";
WsdlOpParameterList parameters = wsdlOperation.getParameters();
if (parameters != null && parameters.getOperation() != null && parameters.getOperation().getInput() != null && parameters.getOperation().getInput().getName() != null) {
request = wsdlOperation.getParameters().getOperation().getInput().getName().toString();
}
wOperationRequest.setText(request);
for (int cpt = 0; cpt < wsdlOperation.getParameters().size(); cpt++) {
WsdlOpParameter param = wsdlOperation.getParameters().get(cpt);
if (param.isArray()) {
// setInFieldArgumentName(param.getName().getLocalPart());
if (param.getItemXmlType() != null) {
ComplexType type = param.getItemComplexType();
if (type != null) {
for (Iterator<String> itrType = type.getElementNames().iterator(); itrType.hasNext(); ) {
String attributeName = itrType.next();
QName attributeType = type.getElementType(attributeName);
if (!WebServiceMeta.XSD_NS_URI.equals(attributeType.getNamespaceURI())) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0007.UnsupporteOperation.ComplexType"));
}
}
}
if (ParameterMode.IN.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
if (inWsdlParamContainer != null) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0006.UnsupportedOperation.MultipleArrays"));
} else {
inWsdlParamContainer = new WsdlOpParameterContainer(param);
}
} else if (ParameterMode.OUT.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
if (outWsdlParamContainer != null) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0006.UnsupportedOperation.MultipleArrays"));
} else {
outWsdlParamContainer = new WsdlOpParameterContainer(param);
}
}
}
} else {
if (ParameterMode.IN.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
if (inWsdlParamContainer != null && !(inWsdlParamContainer instanceof WsdlOperationContainer)) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0008.UnsupportedOperation.IncorrectParams"));
} else {
inWsdlParamContainer = new WsdlOperationContainer(wsdlOperation, param.getMode());
}
} else if (ParameterMode.OUT.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
if (outWsdlParamContainer != null && !(outWsdlParamContainer instanceof WsdlOperationContainer)) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0008.UnsupportedOperation.IncorrectParams"));
} else {
outWsdlParamContainer = new WsdlOperationContainer(wsdlOperation, param.getMode());
}
} else {
System.out.println("Parameter : " + param.getName().getLocalPart() + ", mode=" + param.getMode().toString() + ", is not considered");
}
}
}
if (wsdlOperation.getReturnType() != null) {
outWsdlParamContainer = new WsdlOpParameterContainer((WsdlOpParameter) wsdlOperation.getReturnType());
if (wsdlOperation.getReturnType().isArray()) {
if (wsdlOperation.getReturnType().getItemXmlType() != null) {
ComplexType type = wsdlOperation.getReturnType().getItemComplexType();
if (type != null) {
for (Iterator<String> itrType = type.getElementNames().iterator(); itrType.hasNext(); ) {
String attributeName = itrType.next();
QName attributeType = type.getElementType(attributeName);
if (!WebServiceMeta.XSD_NS_URI.equals(attributeType.getNamespaceURI())) {
throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0007.UnsupportedOperation.ComplexType"));
}
}
}
}
}
}
}
}
Aggregations