Search in sources :

Example 1 with TMDMService_Service

use of com.amalto.workbench.webservices.TMDMService_Service in project tmdm-studio-se by Talend.

the class Util method getMDMService.

public static TMDMService getMDMService(URL url, final String username, final String password, boolean showMissingJarDialog) throws XtentisException {
    url = checkAndAddSuffix(url);
    boolean needCheck = true;
    TMDMService service = (TMDMService) cachedMDMService.get(url, username, password);
    if (service == null) {
        needCheck = false;
        boolean checkResult = MissingJarService.getInstance().checkMissingJar(showMissingJarDialog);
        if (!checkResult) {
            // $NON-NLS-1$
            throw new MissingJarsException("Missing dependency libraries.");
        }
        try {
            TMDMService_Service service_service = new TMDMService_Service(url);
            service = service_service.getTMDMPort();
            BindingProvider stub = (BindingProvider) service;
            // Do not maintain session via cookies
            stub.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, false);
            Map<String, Object> context = stub.getRequestContext();
            // // dynamic set endpointAddress
            // context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
            // authentication
            context.put(BindingProvider.USERNAME_PROPERTY, username);
            context.put(BindingProvider.PASSWORD_PROPERTY, password);
            IWebServiceHook wsHook = getWebServiceHook();
            if (wsHook != null) {
                wsHook.preRequestSendingHook(stub, username);
            }
            cachedMDMService.put(url, username, password, service);
        } catch (WebServiceException e) {
            XtentisException ex = convertWebServiceException(e);
            log.error(Messages.bind(Messages.UnableAccessEndpoint, url, e.getMessage()), e);
            if (ex != null) {
                throw ex;
            }
        }
    }
    if (needCheck) {
        try {
            service.ping(new WSPing());
        } catch (WebServiceException e) {
            cachedMDMService.remove(url, username, password);
            XtentisException ex = convertWebServiceException(e);
            log.error(Messages.bind(Messages.UnableAccessEndpoint, url, e.getMessage()), e);
            if (ex != null) {
                throw ex;
            }
        }
    }
    return service;
}
Also used : WSPing(com.amalto.workbench.webservices.WSPing) MissingJarsException(com.amalto.workbench.service.MissingJarsException) WebServiceException(javax.xml.ws.WebServiceException) TMDMService(com.amalto.workbench.webservices.TMDMService) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) IWebServiceHook(com.amalto.workbench.service.IWebServiceHook) BindingProvider(javax.xml.ws.BindingProvider) TMDMService_Service(com.amalto.workbench.webservices.TMDMService_Service)

Aggregations

TreeObject (com.amalto.workbench.models.TreeObject)1 IWebServiceHook (com.amalto.workbench.service.IWebServiceHook)1 MissingJarsException (com.amalto.workbench.service.MissingJarsException)1 TMDMService (com.amalto.workbench.webservices.TMDMService)1 TMDMService_Service (com.amalto.workbench.webservices.TMDMService_Service)1 WSPing (com.amalto.workbench.webservices.WSPing)1 XObject (com.sun.org.apache.xpath.internal.objects.XObject)1 BindingProvider (javax.xml.ws.BindingProvider)1 WebServiceException (javax.xml.ws.WebServiceException)1 EObject (org.eclipse.emf.ecore.EObject)1