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