Search in sources :

Example 1 with WsdlOperation

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);
            }
        }
    }
}
Also used : WsdlOperation(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Properties(java.util.Properties) Wsdl(org.pentaho.di.trans.steps.webservices.wsdl.Wsdl) URI(java.net.URI) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 2 with WsdlOperation

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"));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : WsdlOperation(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation) WsdlOpParameterContainer(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterContainer) WsdlOpParameterList(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterList) KettleStepException(org.pentaho.di.core.exception.KettleStepException) WsdlOperationContainer(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperationContainer) QName(javax.xml.namespace.QName) WsdlOpParameter(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameter) ComplexType(org.pentaho.di.trans.steps.webservices.wsdl.ComplexType)

Aggregations

KettleStepException (org.pentaho.di.core.exception.KettleStepException)2 WsdlOperation (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation)2 URI (java.net.URI)1 Properties (java.util.Properties)1 QName (javax.xml.namespace.QName)1 KettleException (org.pentaho.di.core.exception.KettleException)1 ComplexType (org.pentaho.di.trans.steps.webservices.wsdl.ComplexType)1 Wsdl (org.pentaho.di.trans.steps.webservices.wsdl.Wsdl)1 WsdlOpParameter (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameter)1 WsdlOpParameterContainer (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterContainer)1 WsdlOpParameterList (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterList)1 WsdlOperationContainer (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperationContainer)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1