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:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Retrieve and display some user details.
 *
 * @return Returns true if getUsersDetail is successful, and false otherwise.
 *
 *******************************************************************************************************************
 */// w w w .j a v  a2s  .  c  o m
public static boolean displayUserDetails() {
    final String METHOD_NAME = "displayUserDetails()";
    final String BWS_API_NAME = "_bws.getUsersDetail()";
    logMessage("Entering %s", METHOD_NAME);
    boolean returnValue = false;

    logMessage("Displaying details for user with email address \"%s\"", DISPLAY_USER_DETAIL_EMAIL);

    // Getting the user object.
    User user = getUser();

    if (user == null) {
        logMessage("'user' is null");
        logMessage("Exiting %s with value \"%s\"", METHOD_NAME, returnValue);
        return returnValue;
    }

    GetUsersDetailRequest request = new GetUsersDetailRequest();
    request.setMetadata(REQUEST_METADATA);

    /*
     * To help improve API performance, load only the required details.
     * By default all load flags are set to false.
     */
    request.setLoadAccounts(true);
    request.setLoadDevices(true);
    request.setLoadITPolicies(true);
    request.getUsers().add(user);

    GetUsersDetailResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bws.getUsersDetail(request);
        logResponse(BWS_API_NAME, response.getReturnStatus().getCode(), response.getMetadata());
    } catch (WebServiceException e) {
        // Log and re-throw exception.
        logMessage("Exiting %s with exception \"%s\"", METHOD_NAME, e.getMessage());
        throw e;
    }

    if (response.getReturnStatus().getCode().equals("SUCCESS")) {
        if (response.getIndividualResponses() != null && response.getIndividualResponses().size() == 1) {
            for (GetUsersDetailIndividualResponse individualResponse : response.getIndividualResponses()) {
                UserDetail userDetail = individualResponse.getUserDetail();

                displayResult("User details:");
                // The values of the fields, and whether they will be populated or not, depends on the device type.
                displayResult("Display Name: %s", userDetail.getDisplayName());
                displayResult("User UID: %s", individualResponse.getUserUid());
                // Displays time in UTC format.
                displayResult("Last Login Time: %s", userDetail.getLastLoginTime());
                if (userDetail.getIndirectITPolicies() != null
                        && !userDetail.getIndirectITPolicies().isEmpty()) {
                    StringBuilder policyString = new StringBuilder();
                    for (IndirectITPolicy indirectITPolicy : userDetail.getIndirectITPolicies()) {
                        if (policyString.length() > 0) {
                            policyString.append(", ");
                        }
                        policyString.append(indirectITPolicy.getItPolicy().getPolicy().getName());
                    }
                    displayResult("Indirect IT policy names: %s", policyString);
                }

                if (userDetail.getDirectITPolicy() != null
                        && userDetail.getDirectITPolicy().getPolicy() != null) {
                    displayResult("Direct IT policy name: %s",
                            userDetail.getDirectITPolicy().getPolicy().getName());
                }

                /*
                 * The BWS object model supports multiple accounts and devices. However, BlackBerry Enterprise Server 5.0.x
                 * will only return at most one object in the userDetail.getDevices() list, and at most one object in the
                 * userDetail.getAccounts() list.
                 */
                if (userDetail.getDevices() != null && !userDetail.getDevices().isEmpty()) {
                    displayResult("User's device details:");

                    int deviceIndex = 1;
                    for (Device device : userDetail.getDevices()) {
                        displayResult("Device %d data", (deviceIndex++));
                        displayResult("---------------");
                        displayResult("PIN: %s", device.getPin());
                        displayResult("Model: %s", device.getModel());
                        displayResult("Phone Number: %s", device.getPhoneNumber());

                        displayResult("Active Carrier: %s", device.getActiveCarrier());
                        displayResult("Serial Number: %s", device.getSerialNumber());

                        displayResult("State: %s", device.getState().getValue());
                        displayResult("IT Policy Name: %s", device.getItPolicyName());

                        displayResult("Platform Version: %s", device.getPlatformVersion());

                        displayResult("---------------");
                    }
                }

                if (userDetail.getAccounts() != null && !userDetail.getAccounts().isEmpty()) {
                    displayResult("User's account details:");

                    int accountIndex = 1;
                    for (Account account : userDetail.getAccounts()) {
                        displayResult("Account %d data", (accountIndex++));
                        displayResult("---------------");
                        displayResult("Email Address: %s", account.getEmailAddress());
                        displayResult("---------------");
                    }
                }
            }

            returnValue = true;
        } else if (response.getIndividualResponses() != null && response.getIndividualResponses().size() > 1) {
            logMessage("More than one user was found with userUid \"%s\"", user.getUid());
        } else {
            logMessage("No user was found with userUid \"%s\"", user.getUid());
        }
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
        if (response.getIndividualResponses() != null) {
            for (GetUsersDetailIndividualResponse individualResponse : response.getIndividualResponses()) {
                logMessage("User UID: \"%s\"", individualResponse.getUserUid());
                logMessage("Individual Response - Code: \"%s\", Message: \"%s\"",
                        individualResponse.getReturnStatus().getCode(),
                        individualResponse.getReturnStatus().getMessage());
            }
        }
    }

    logMessage("Exiting %s with value \"%s\"", METHOD_NAME, returnValue);
    return returnValue;
}

From source file:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Call bwsService.getSystemInfo() and set the _serverType member.
 *
 *****************************************************************************************************************
 *//* ww  w. j  a v a2  s .com*/
public static void getSystemInfo() {
    final String METHOD_NAME = "getSystemInfo()";
    final String BWS_API_NAME = "_bws.getSystemInfo()";

    logMessage("Entering %s", METHOD_NAME);

    GetSystemInfoRequest request = new GetSystemInfoRequest();
    request.setLoadAuthenticatedUserProperties(false);
    request.setMetadata(REQUEST_METADATA);

    GetSystemInfoResponse response = null;

    /*
     * The try catch block here is used to illustrate how to handle a specific type of exception.
     * For example, in this case we check to see if the error was caused by invalid credentials.
     */
    try {
        logRequest(BWS_API_NAME);
        response = _bws.getSystemInfo(request);
        logResponse(BWS_API_NAME, response.getReturnStatus().getCode(), response.getMetadata());
    } catch (WebServiceException e) {
        if (e.getCause() instanceof HTTPException) {
            HTTPException httpException = (HTTPException) e.getCause();
            // Handle authentication failure.
            if (httpException != null
                    && httpException.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                logMessage("Failed to authenticate with the BWS web service");
            }
        }

        // Log and re-throw exception.
        logMessage("Exiting %s with exception \"%s\"", METHOD_NAME, e.getMessage());
        throw e;
    }

    if (response.getReturnStatus().getCode().equals("SUCCESS")) {
        if (response.getProperties() != null && !response.getProperties().isEmpty()) {
            for (Property property : response.getProperties()) {
                if (property.getName().equalsIgnoreCase("BAS Version")) {
                    if (property.getValue().split("\\.")[0].equals("12")) // 10 is BDS
                    {
                        _serverType = ServerType.BES12;
                        logMessage("ServerType found: BES12/UEM");
                    } else {
                        _serverType = ServerType.BDS;
                        logMessage("ServerType found: BDS");
                    }
                    break;
                }
                if (property.getName().equalsIgnoreCase("BUDS Version")) {
                    _serverType = ServerType.UDS;
                    logMessage("ServerType found: UDS");
                    break;
                }
            }
        } else {
            logMessage("No properties in response");
        }
    } else {
        System.err.format("Error: Code: \"%s\", Message: \"%s\"%n", response.getReturnStatus().getCode(),
                response.getReturnStatus().getMessage());
    }

    logMessage("Exiting %s", METHOD_NAME);
}

From source file:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Perform a call to _bws.echo().//from w  ww . ja va 2  s . c om
 *
 * @return Returns true if echo is successful, and false otherwise.
 *
 *****************************************************************************************************************
 */
public static boolean echo() throws WebServiceException {
    final String METHOD_NAME = "echo()";
    final String BWS_API_NAME = "_bws.echo()";
    logMessage("Entering %s", METHOD_NAME);

    boolean returnValue = true;

    EchoRequest request = new EchoRequest();
    EchoResponse response = null;

    request.setMetadata(REQUEST_METADATA);
    request.setText("Hello World!");

    try {
        logRequest(BWS_API_NAME);
        response = _bws.echo(request);
        logResponse(BWS_API_NAME, response.getReturnStatus().getCode(), response.getMetadata());
    } catch (WebServiceException e) {
        if (e.getCause() instanceof HTTPException) {
            HTTPException httpException = (HTTPException) e.getCause();
            // Handle authentication failure.
            if (httpException != null
                    && httpException.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
                returnValue = false;
                logMessage("Failed to authenticate with the BWS web service");
                logMessage("Exiting %s with value \"%s\"", METHOD_NAME, returnValue);
                return returnValue;
            }
        }

        // Log and re-throw exception.
        logMessage("Exiting %s with exception \"%s\"", METHOD_NAME, e.getMessage());
        throw e;
    }

    logMessage("Exiting %s with value \"%s\"", METHOD_NAME, returnValue);
    return returnValue;
}

From source file:com.amalto.workbench.editors.ServiceConfigrationMainPage.java

protected String getDoc() {
    try {//from ww w.  j  a  v a2s  .c o m
        WSServiceGetDocument doc = getServiceDocument(serviceNameCombo.getText());
        return doc.getDefaultConfig();
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.amalto.workbench.editors.ServiceConfigrationMainPage.java

protected String getDesc() {
    try {/*from  w w  w .j a v a  2 s.c  om*/
        WSServiceGetDocument doc = getServiceDocument(serviceNameCombo.getText());
        return doc.getDescription();
    } catch (WebServiceException e) {
        log.error(e.getMessage(), e);
    }
    return null;
}

From source file:com.clustercontrol.infra.util.InfraEndpointWrapper.java

public void addInfraFile(InfraFileInfo info, String filePath)
        throws HinemosUnknown_Exception, InfraFileTooLarge_Exception, InvalidRole_Exception,
        InvalidUserPass_Exception, InfraManagementDuplicate_Exception {
    WebServiceException wse = null;
    for (EndpointSetting<InfraEndpoint> endpointSetting : getInfraEndpoint(endpointUnit)) {
        try {// w ww.j av  a  2s. c om
            InfraEndpoint endpoint = endpointSetting.getEndpoint();
            endpoint.addInfraFile(info, new DataHandler(new FileDataSource(filePath)));
            return;
        } catch (WebServiceException e) {
            wse = e;
            m_log.warn("addInfraFile(), " + e.getMessage());
            endpointUnit.changeEndpoint();
        }
    }
    throw wse;
}

From source file:com.clustercontrol.infra.util.InfraEndpointWrapper.java

public List<InfraCheckResult> getCheckResultList(String managementId)
        throws HinemosUnknown_Exception, InvalidRole_Exception, InvalidUserPass_Exception {
    WebServiceException wse = null;
    for (EndpointSetting<InfraEndpoint> endpointSetting : getInfraEndpoint(endpointUnit)) {
        try {/*  w w w  .  j  a  va 2 s.c  o  m*/
            InfraEndpoint endpoint = endpointSetting.getEndpoint();
            return endpoint.getCheckResultList(managementId);
        } catch (WebServiceException e) {
            wse = e;
            m_log.warn("getCheckResults(), " + e.getMessage());
            endpointUnit.changeEndpoint();
        }
    }
    throw wse;
}

From source file:com.clustercontrol.infra.util.InfraEndpointWrapper.java

public ModuleResult runInfraModule(String sessionId)
        throws HinemosUnknown_Exception, InfraManagementNotFound_Exception, InfraModuleNotFound_Exception,
        InvalidRole_Exception, InvalidUserPass_Exception, SessionNotFound_Exception {
    WebServiceException wse = null;
    ModuleResult ret = null;//from   ww w.ja  va 2s.c  o m
    for (EndpointSetting<InfraEndpoint> endpointSetting : getInfraEndpoint(endpointUnit)) {
        try {
            InfraEndpoint endpoint = endpointSetting.getEndpoint();
            ret = endpoint.runInfraModule(sessionId);
            return ret;
        } catch (WebServiceException e) {
            wse = e;
            m_log.warn("runInfraModule(), " + e.getMessage());
            endpointUnit.changeEndpoint();
        }
    }
    throw wse;
}

From source file:com.clustercontrol.infra.util.InfraEndpointWrapper.java

public List<InfraFileInfo> getInfraFileList()
        throws HinemosUnknown_Exception, InvalidRole_Exception, InvalidUserPass_Exception {
    WebServiceException wse = null;
    for (EndpointSetting<InfraEndpoint> endpointSetting : getInfraEndpoint(endpointUnit)) {
        try {//from   w  w  w.  j  a  v  a 2s  .c o  m
            InfraEndpoint endpoint = endpointSetting.getEndpoint();
            List<InfraFileInfo> list = endpoint.getInfraFileList();
            return list;
        } catch (WebServiceException e) {
            wse = e;
            m_log.warn("getInfraFileList(), " + e.getMessage());
            endpointUnit.changeEndpoint();
        }
    }
    throw wse;
}

From source file:com.clustercontrol.infra.util.InfraEndpointWrapper.java

public DataHandler downloadInfraFile(String fileId, String fileName)
        throws HinemosUnknown_Exception, InfraFileNotFound_Exception, InvalidRole_Exception,
        InvalidSetting_Exception, InvalidUserPass_Exception, IOException_Exception {
    WebServiceException wse = null;
    for (EndpointSetting<InfraEndpoint> endpointSetting : getInfraEndpoint(endpointUnit)) {
        try {// ww  w  .  j  av  a  2  s  .  c o  m
            InfraEndpoint endpoint = endpointSetting.getEndpoint();
            return endpoint.downloadInfraFile(fileId, fileName);
        } catch (WebServiceException e) {
            wse = e;
            m_log.warn("downloadInfraFile(), " + e.getMessage());
            endpointUnit.changeEndpoint();
        }
    }
    throw wse;
}