Search in sources :

Example 6 with RestServiceReference

use of com.twinsoft.convertigo.beans.references.RestServiceReference in project convertigo by convertigo.

the class WsReference method importInto.

protected HttpConnector importInto(Project project) throws Exception {
    boolean needAuthentication = false;
    try {
        if (project != null) {
            RemoteFileReference wsReference = getReference();
            if (wsReference != null) {
                String wsdlUrl = wsReference.getUrlpath();
                // test for valid URL
                new URL(wsdlUrl);
                needAuthentication = wsReference.needAuthentication();
                // SOAP web service
                if (wsReference instanceof WebServiceReference) {
                    try {
                        // Configure SoapUI settings
                        configureSoapUI(wsdlUrl);
                        // Authenticate
                        if (needAuthentication) {
                            String login = wsReference.getAuthUser();
                            String password = wsReference.getAuthPassword();
                            try {
                                // We add login/password into the connection
                                System.setProperty("soapui.loader.username", login);
                                System.setProperty("soapui.loader.password", password);
                                tryAuthentication(wsReference);
                            } catch (Exception e) {
                                throw new Exception("Authentication failure !", e);
                            }
                        }
                        WebServiceReference soapServiceReference = (WebServiceReference) wsReference;
                        return importSoapWebService(project, soapServiceReference);
                    } finally {
                        if (needAuthentication) {
                            // We clear login/password
                            System.setProperty("soapui.loader.username", "");
                            System.setProperty("soapui.loader.password", "");
                        }
                    }
                }
                // REST web service
                if (wsReference instanceof RestServiceReference) {
                    RestServiceReference restServiceReference = (RestServiceReference) wsReference;
                    return importRestWebService(project, restServiceReference);
                }
            }
        }
    } catch (Throwable t) {
        throw new EngineException("Unable to import the web service reference", t);
    }
    return null;
}
Also used : RestServiceReference(com.twinsoft.convertigo.beans.references.RestServiceReference) EngineException(com.twinsoft.convertigo.engine.EngineException) RemoteFileReference(com.twinsoft.convertigo.beans.references.RemoteFileReference) WebServiceReference(com.twinsoft.convertigo.beans.references.WebServiceReference) URL(java.net.URL) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Aggregations

RestServiceReference (com.twinsoft.convertigo.beans.references.RestServiceReference)6 WebServiceReference (com.twinsoft.convertigo.beans.references.WebServiceReference)6 RemoteFileReference (com.twinsoft.convertigo.beans.references.RemoteFileReference)4 Project (com.twinsoft.convertigo.beans.core.Project)3 EngineException (com.twinsoft.convertigo.engine.EngineException)3 ImportWsReference (com.twinsoft.convertigo.engine.util.ImportWsReference)3 HttpConnector (com.twinsoft.convertigo.beans.connectors.HttpConnector)2 SqlConnector (com.twinsoft.convertigo.beans.connectors.SqlConnector)2 Connector (com.twinsoft.convertigo.beans.core.Connector)2 File (java.io.File)2 URL (java.net.URL)2 CicsConnector (com.twinsoft.convertigo.beans.connectors.CicsConnector)1 HtmlConnector (com.twinsoft.convertigo.beans.connectors.HtmlConnector)1 JavelinConnector (com.twinsoft.convertigo.beans.connectors.JavelinConnector)1 SapJcoConnector (com.twinsoft.convertigo.beans.connectors.SapJcoConnector)1 SiteClipperConnector (com.twinsoft.convertigo.beans.connectors.SiteClipperConnector)1 Criteria (com.twinsoft.convertigo.beans.core.Criteria)1 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 ScreenClass (com.twinsoft.convertigo.beans.core.ScreenClass)1 Sheet (com.twinsoft.convertigo.beans.core.Sheet)1