Example usage for javax.xml.ws WebServiceException getCause

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

Introduction

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

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Perform a call to _bws.echo()./* w w  w.j a v  a 2s  .  co  m*/
 *
 * @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:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Call bwsService.getSystemInfo() and set the _serverType member.
 *
 *****************************************************************************************************************
 *///  w w 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:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Call _bwsService.getSystemInfo() and display the returned properties.
 *
 * @return Returns true if getSystemInfo is successful, and false otherwise.
 *
 *******************************************************************************************************************
 *//*from w  w  w  . java 2s .  c  o  m*/
public static boolean getSystemInfo() {
    final String METHOD_NAME = "getSystemInfo()";
    final String BWS_API_NAME = "_bws.getSystemInfo()";

    logMessage("Entering %s", METHOD_NAME);
    boolean returnValue = false;

    GetSystemInfoRequest request = new GetSystemInfoRequest();

    /*
     * Setting the value of loadAuthenticatedUserProperties to true will cause the API to return additional
     * properties about the current user, like the Authenticated User Uid property. The Authenticated User Uid
     * property is often used to make calls to APIs like getUsersDetail(), assignSWConfigsToGroup() and
     * others.
     *
     * Valid for BlackBerry Enterprise Server 5.0.3 MR5 or later
     */
    request.setLoadAuthenticatedUserProperties(true);
    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");
                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;

    }

    if (response.getReturnStatus().getCode().equals("SUCCESS")) {
        if (response.getProperties() != null && !response.getProperties().isEmpty()) {
            logMessage("%s returned the following properties:", BWS_API_NAME);
            for (Property property : response.getProperties()) {
                displayResult("%s: %s", property.getName(), property.getValue());
            }

            returnValue = true;
        } 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 with value \"%s\"", METHOD_NAME, returnValue);
    return returnValue;
}

From source file:com.docdoku.client.actions.MainController.java

public void delDocM(DocumentMaster pDocumentMaster) throws Exception {
    try {/*from w  w  w .j  a v a  2  s .  co m*/
        System.out.println("Deleting document master " + pDocumentMaster);
        mDocumentService.deleteDocumentMaster(pDocumentMaster.getKey());
        MainModel.getInstance().updater.delDocM(pDocumentMaster);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void delDocMTemplate(DocumentMasterTemplate pDocMTemplate) throws Exception {
    try {//from  w  ww  . j  a  v a2s  .c o  m
        System.out.println("Deleting document master template " + pDocMTemplate);
        mDocumentService.deleteDocumentMasterTemplate(pDocMTemplate.getKey());
        MainModel.getInstance().updater.delDocMTemplate(pDocMTemplate);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void createFolder(String pParentFolder, String pFolder) throws Exception {
    try {/*from  w w w . j  a  v a 2s.c  om*/
        System.out.println("Creating folder " + pFolder + " in " + pParentFolder);
        mDocumentService.createFolder(pParentFolder, pFolder);
        MainModel.getInstance().updater.createFolder(pParentFolder, pFolder);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void subscribeStateNotification(DocumentMaster pDocumentMaster) throws Exception {
    try {/*from   ww w. j  a va2 s  . c om*/
        System.out.println("Subscribe state notification on document master " + pDocumentMaster);
        mDocumentService.subscribeToStateChangeEvent(pDocumentMaster.getKey());
        MainModel.getInstance().updater.addStateNotification(pDocumentMaster);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void unsubscribeStateNotification(DocumentMaster pDocumentMaster) throws Exception {
    try {//from   w  w  w  .  j  a  v  a 2s. com
        System.out.println("Unsubscribe state notification on document master " + pDocumentMaster);
        mDocumentService.unsubscribeToStateChangeEvent(pDocumentMaster.getKey());
        MainModel.getInstance().updater.removeStateNotification(pDocumentMaster);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void subscribeIterationNotification(DocumentMaster pDocumentMaster) throws Exception {
    try {//  w w w. ja  va 2  s.  c  o m
        System.out.println("Subscribe iteration notification on document master " + pDocumentMaster);
        mDocumentService.subscribeToIterationChangeEvent(pDocumentMaster.getKey());
        MainModel.getInstance().updater.addIterationNotification(pDocumentMaster);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}

From source file:com.docdoku.client.actions.MainController.java

public void unsubscribeIterationNotification(DocumentMaster pDocumentMaster) throws Exception {
    try {//from   ww w. j  a  v  a  2s.  co m
        System.out.println("Unsubscribe iteration notification on document master " + pDocumentMaster);
        mDocumentService.unsubscribeToIterationChangeEvent(pDocumentMaster.getKey());
        MainModel.getInstance().updater.removeIterationNotification(pDocumentMaster);
    } catch (WebServiceException pWSEx) {
        Throwable t = pWSEx.getCause();
        if (t instanceof Exception) {
            throw (Exception) t;
        } else {
            throw pWSEx;
        }
    }
}