Example usage for javax.xml.ws WebServiceException getMessage

List of usage examples for javax.xml.ws WebServiceException getMessage

Introduction

In this page you can find the example usage for javax.xml.ws WebServiceException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.amalto.workbench.utils.Util.java

public static TMDMService getMDMService(URL url, final String username, final String password,
        boolean showMissingJarDialog) throws XtentisException {
    url = checkAndAddSuffix(url);//w w w  .  jav  a  2 s .  c  om

    boolean needCheck = true;
    TMDMService service = (TMDMService) cachedMDMService.get(url, username, password);
    if (service == null) {
        needCheck = false;

        boolean checkResult = MissingJarService.getInstance().checkMissingJar(showMissingJarDialog);
        if (!checkResult) {
            throw new MissingJarsException("Missing dependency libraries."); //$NON-NLS-1$
        }

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

From source file:org.apache.axis2.jaxws.client.async.CallbackFuture.java

public void onComplete(org.apache.axis2.context.MessageContext mc) {
    if (debug) {/*from   w w w  . j  a v  a 2  s . c om*/
        log.debug("JAX-WS received the async response");
    }

    MessageContext response = null;
    try {
        response = AsyncUtils.createJAXWSMessageContext(mc);
        response.setInvocationContext(invocationCtx);
        // make sure request and response contexts share a single parent
        response.setMEPContext(invocationCtx.getRequestMessageContext().getMEPContext());
    } catch (WebServiceException e) {
        cft.setError(e);
        if (debug) {
            log.debug("An error occured while processing the async response.  " + e.getMessage());
        }
    }

    if (response == null) {
        // TODO: throw an exception
    }

    cft.setMessageContext(response);
    execute();
}

From source file:org.apache.axis2.jaxws.client.async.PollingFuture.java

public void onComplete(org.apache.axis2.context.MessageContext msgContext) {
    boolean debug = log.isDebugEnabled();
    if (debug) {/*from  w w w.  j  av a  2s. c om*/
        log.debug("JAX-WS async response listener received the response");
    }

    MessageContext responseMsgCtx = null;
    try {
        responseMsgCtx = AsyncUtils.createJAXWSMessageContext(msgContext);
        responseMsgCtx.setInvocationContext(invocationCtx);
        // make sure request and response contexts share a single parent
        responseMsgCtx.setMEPContext(invocationCtx.getRequestMessageContext().getMEPContext());
    } catch (WebServiceException e) {
        response.onError(e, null);
        if (debug) {
            log.debug("An error occured while processing the async response.  " + e.getMessage());
        }
    }

    if (response == null) {
        // TODO: throw an exception
    }

    response.onComplete(responseMsgCtx);
}

From source file:org.apache.axis2.jaxws.ExceptionFactory.java

/**
 * Create a WebServiceException//w  ww.j ava  2  s.co  m
 *
 * @param message
 * @param t       Throwable
 * @return WebServiceException
 */
private static WebServiceException createWebServiceException(String message, Throwable t) {

    // We might have an embedded WebServiceException that has a good message on it
    WebServiceException me = (WebServiceException) findException(t, WebServiceException.class);
    if (me != null) {
        String meMessage = me.getMessage();
        if (meMessage != null) {
            if (message == null) {
                message = meMessage;
            } else {
                message = message + ": " + meMessage;
            }
        }
    }

    // Get the root cause.  We want to strip out the intermediate exceptions (like AxisFault) because
    // these won't make sense to the user.
    Throwable rootCause = null;
    if (t != null) {
        rootCause = getRootCause(t);
    }
    rootCause = rootCause == null ? t : rootCause;
    WebServiceException e = null;

    // The root cause may not have a good message.  We might want to enhance it
    String enhancedMessage = enhanceMessage(rootCause);
    if (enhancedMessage != null) {
        if (message != null)
            message = message + ": " + enhancedMessage;
        else
            message = enhancedMessage;
    }

    if (message != null) {
        e = new WebServiceException(message, rootCause);
    } else {
        e = new WebServiceException(rootCause);
    }

    if (log.isDebugEnabled()) {
        log.debug("Create Exception:", e);
    }
    return e;
}

From source file:org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.java

/**
 * This method is used by WebService Impl and Provider to create an XMLFault (for marshalling)
 * from an exception that is a non-service exception
 *
 * @param t Throwable that represents a Service Exception
 * @return XMLFault/*from   w ww . j av  a  2  s. c o  m*/
 */
public static XMLFault createXMLFaultFromSystemException(Throwable t) {

    try {
        XMLFault xmlfault = null;
        if (t instanceof SOAPFaultException) {
            if (log.isErrorEnabled()) {
                log.debug("Marshal SOAPFaultException");
            }
            // Category C: SOAPFaultException 
            // Construct the xmlFault from the SOAPFaultException's Fault
            SOAPFaultException sfe = (SOAPFaultException) t;
            SOAPFault soapFault = sfe.getFault();
            if (soapFault == null) {
                // No fault ?  I will treat this like category E
                xmlfault = new XMLFault(null, // Use the default XMLFaultCode
                        new XMLFaultReason(t.toString())); // Assumes text lang of current Locale
            } else {
                xmlfault = XMLFaultUtils.createXMLFault(soapFault);
            }

        } else if (t instanceof WebServiceException) {
            if (log.isErrorEnabled()) {
                log.debug("Marshal as a WebServiceException");
            }
            // Category D: WebServiceException
            // The reason is constructed with the getMessage of the exception.  
            // There is no detail
            WebServiceException wse = (WebServiceException) t;

            // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
            String text = wse.getMessage();
            if (text == null || text.length() == 0) {
                text = wse.toString();
            }
            xmlfault = new XMLFault(null, // Use the default XMLFaultCode
                    new XMLFaultReason(text)); // Assumes text lang of current Locale
        } else {
            if (log.isErrorEnabled()) {
                log.debug("Marshal as a unchecked System Exception");
            }
            // Category E: Other System Exception
            // The reason is constructed with the toString of the exception.  
            // This places the class name of the exception in the reason
            // There is no detail.
            // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
            String text = t.getMessage();
            if (text == null || text.length() == 0) {
                text = t.toString();
            }
            xmlfault = new XMLFault(null, // Use the default XMLFaultCode
                    new XMLFaultReason(text)); // Assumes text lang of current Locale
        }
        return xmlfault;
    } catch (Throwable e) {
        try {
            // If an exception occurs while demarshalling an exception, 
            // then rinse and repeat with a webservice exception
            if (log.isDebugEnabled()) {
                log.debug("An exception (" + e + ") occurred while marshalling exception (" + t + ")");
            }
            // Get the fault text using algorithm defined in JAX-WS 10.2.2.3
            String text = e.getMessage();
            if (text == null || text.length() == 0) {
                text = e.toString();
            }
            WebServiceException wse = ExceptionFactory.makeWebServiceException(e);

            return new XMLFault(null, // Use the default XMLFaultCode
                    new XMLFaultReason(text)); // Assumes text lang of current Locale
        } catch (Exception e2) {
            // Exception while creating Exception for Exception
            throw ExceptionFactory.makeWebServiceException(e2);
        }
    }
}

From source file:org.kuali.kfs.module.external.kc.service.impl.AwardAccountServiceImpl.java

@Override
public Collection findMatching(Map fieldValues) {
    String accountNumber = (String) fieldValues.get(KFSPropertyConstants.ACCOUNT_NUMBER);
    if (StringUtils.isBlank(accountNumber)) {
        accountNumber = null; // don't pass an empty string account number to KC
    }/* w  w w.j  av  a2 s  . co m*/
    String chartOfAccountsCode = (String) fieldValues.get(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
    if (StringUtils.isBlank(chartOfAccountsCode)) {
        chartOfAccountsCode = null; // don't pass an empty string chart code to KC
    }

    List awardAccounts = new ArrayList();
    List<AwardAccountDTO> awardAccountDTOs = null;

    //get award account DTO
    try {
        awardAccountDTOs = getWebService().getAwardAccounts(accountNumber, chartOfAccountsCode);
    } catch (WebServiceException ex) {
        LOG.error("Could not retrieve award accounts: " + ex.getMessage());
    }

    if (awardAccountDTOs != null && !awardAccountDTOs.isEmpty()) {
        ContractsAndGrantsBillingAwardAccount awardAccountInfo = null;

        for (AwardAccountDTO awardAccount : awardAccountDTOs) {
            //create if no error messages
            if (StringUtils.isEmpty(awardAccount.getErrorMessage())) {
                awardAccountInfo = new AwardAccount(awardAccount, accountNumber, chartOfAccountsCode, "");
                awardAccounts.add(awardAccountInfo);
            }
        }
    }

    return awardAccounts;
}

From source file:org.kuali.kra.budget.external.budget.impl.BudgetAdjustmentClientBase.java

@Override
public void createBudgetAdjustmentDocument(AwardBudgetDocument awardBudgetDocument) throws Exception {
    BudgetAdjustmentParametersDTO parametersDTO = new BudgetAdjustmentParametersDTO();
    boolean complete = setBudgetAdjustmentParameters(awardBudgetDocument, parametersDTO);
    if (complete) {
        try {//  ww  w .java2 s.  com
            BudgetAdjustmentService port = getServiceHandle();
            LOG.info("Invoking createBudgetAdjustment...");
            BudgetAdjustmentCreationStatusDTO budgetAdjustmentStatus = port
                    .createBudgetAdjustment(parametersDTO);

            if (budgetAdjustmentStatus.getStatus().equalsIgnoreCase("success")) {

                // This should never happen.
                if (budgetAdjustmentStatus.getDocumentNumber() == null) {
                    GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_MESSAGES,
                            KeyConstants.DOCUMENT_NUMBER_NULL);
                    awardBudgetDocument.refresh();
                    String completeErrorMessage = "Document number returned from KFS budget adjustment service is null.";
                    GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                            KeyConstants.BUDGET_ADJUSTMENT_DOCUMENT_NOT_CREATED, completeErrorMessage);
                    LOG.warn(completeErrorMessage);

                } else {
                    awardBudgetDocument.getBudget()
                            .setBudgetAdjustmentDocumentNumber(budgetAdjustmentStatus.getDocumentNumber());
                    documentService.saveDocument(awardBudgetDocument);
                }
                //if there are error messages but the document was saved in KFS
                if (ObjectUtils.isNotNull(budgetAdjustmentStatus.getErrorMessages())
                        && !budgetAdjustmentStatus.getErrorMessages().isEmpty()) {
                    String completeErrorMessage = "";
                    List<String> errorMessages = budgetAdjustmentStatus.getErrorMessages();
                    for (String errorMessage : errorMessages) {
                        completeErrorMessage += errorMessage;
                    }
                    GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                            KeyConstants.BUDGET_DOCUMENT_SAVED_WITH_ERRORS, completeErrorMessage);
                }
            } else {
                String completeErrorMessage = "";
                List<String> errorMessages = budgetAdjustmentStatus.getErrorMessages();
                for (String errorMessage : errorMessages) {
                    completeErrorMessage += errorMessage;
                }
                GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                        KeyConstants.BUDGET_ADJUSTMENT_DOCUMENT_NOT_CREATED, completeErrorMessage);
            }
        } catch (WebServiceException e) {
            String errorMessage = "Cannot connect to the service. The service may be down, please try again later.";
            GlobalVariables.getMessageMap().putError(KRADConstants.GLOBAL_ERRORS,
                    KeyConstants.CANNOT_CONNECT_TO_SERVICE);
            LOG.error(errorMessage + e.getMessage(), e);
        }
    }
}

From source file:org.opennaas.extensions.bod.autobahn.protocol.AutobahnProtocolSession.java

private <T> T createSoapService(String uri, QName serviceName, QName portName, Class<T> clazz)
        throws ProtocolException {
    /*/* ww  w .  j  a v  a  2s  .  com*/
     * The JAXWS SPI uses the context class loader to locate an implementation. We therefore make sure the context class loader is set to our
     * class loader.
     */
    Thread thread = Thread.currentThread();
    ClassLoader oldLoader = thread.getContextClassLoader();
    try {
        thread.setContextClassLoader(getClass().getClassLoader());
        Service service = Service.create(serviceName);
        service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING, uri);
        return service.getPort(portName, clazz);
    } catch (WebServiceException e) {
        throw new ProtocolException("Failed to create Autobahn session: " + e.getMessage(), e);
    } finally {
        thread.setContextClassLoader(oldLoader);
    }
}

From source file:org.oscarehr.PMmodule.caisi_integrator.CaisiIntegratorUpdateTask.java

public void pushAllFacilities() throws ShutdownException {
    List<Facility> facilities = facilityDao.findAll(true);

    for (Facility facility : facilities) {
        try {// w  ww. j  a va 2 s  .c o  m
            if (facility.isIntegratorEnabled()) {
                pushAllDataForOneFacility(facility);
                findChangedRecordsFromIntegrator(facility);
            }
        } catch (WebServiceException e) {
            if (CxfClientUtils.isConnectionException(e)) {
                logger.warn("Error connecting to integrator. " + e.getMessage());
                logger.debug("Error connecting to integrator.", e);
            } else {
                logger.error("Unexpected error.", e);
            }
        } catch (ShutdownException e) {
            throw (e);
        } catch (Exception e) {
            logger.error("Unexpected error.", e);
        }
    }
}

From source file:org.oscarehr.PMmodule.web.GenericIntakeSearchAction.java

private void createRemoteList(HttpServletRequest request, GenericIntakeSearchFormBean intakeSearchBean) {
    try {/*from  ww w .ja  v a2 s.co  m*/
        DemographicWs demographicWs = CaisiIntegratorManager.getDemographicWs();

        MatchingDemographicParameters parameters = new MatchingDemographicParameters();
        parameters.setMaxEntriesToReturn(10);
        parameters.setMinScore(7);

        String temp = StringUtils.trimToNull(intakeSearchBean.getFirstName());
        parameters.setFirstName(temp);

        temp = StringUtils.trimToNull(intakeSearchBean.getLastName());
        parameters.setLastName(temp);

        temp = StringUtils.trimToNull(intakeSearchBean.getHealthCardNumber());
        parameters.setHin(temp);

        GregorianCalendar cal = new GregorianCalendar();
        {
            MiscUtils.setToBeginningOfDay(cal);

            temp = StringUtils.trimToNull(intakeSearchBean.getYearOfBirth());
            if (temp != null)
                cal.set(Calendar.YEAR, Integer.parseInt(temp));

            temp = StringUtils.trimToNull(intakeSearchBean.getMonthOfBirth());
            if (temp != null)
                cal.set(Calendar.MONTH, Integer.parseInt(temp));

            temp = StringUtils.trimToNull(intakeSearchBean.getDayOfBirth());
            if (temp != null)
                cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(temp));

            parameters.setBirthDate(cal);
        }

        List<MatchingDemographicTransferScore> integratedMatches = demographicWs
                .getMatchingDemographics(parameters);
        request.setAttribute("remoteMatches", integratedMatches);

        List<CachedFacility> allFacilities = CaisiIntegratorManager.getRemoteFacilities();
        HashMap<Integer, String> facilitiesNameMap = new HashMap<Integer, String>();
        for (CachedFacility cachedFacility : allFacilities)
            facilitiesNameMap.put(cachedFacility.getIntegratorFacilityId(), cachedFacility.getName());

        request.setAttribute("facilitiesNameMap", facilitiesNameMap);
    } catch (WebServiceException e) {
        LOG.warn("Error connecting to integrator. " + e.getMessage());
        LOG.debug("Error connecting to integrator.", e);
    } catch (Exception e) {
        LOG.error("Unexpected error.", e);
    }
}