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:demo.hw.client.SpringClient.java

public static void main(String args[]) throws Exception {
    // START SNIPPET: client
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "/demo/hw/client/client-beans.xml" });

    Greeter port = (Greeter) context.getBean("client");

    String resp;/*from  ww w.  j  a  v  a2 s  .co m*/

    System.out.println("Invoking sayHi...");
    resp = port.sayHi();
    System.out.println("Server responded with: " + resp);
    System.out.println();

    System.out.println("Invoking greetMe...");
    resp = port.greetMe(System.getProperty("user.name"));
    System.out.println("Server responded with: " + resp);
    System.out.println();

    System.out.println("Invoking greetMe with invalid length string, expecting exception...");
    try {
        resp = port.greetMe("Invoking greetMe with invalid length string, expecting exception...");
    } catch (WebServiceException ex) {
        System.out.println("Caught expected WebServiceException:");
        System.out.println("    " + ex.getMessage());
    }

    System.out.println();

    System.out.println("Invoking greetMeOneWay...");
    port.greetMeOneWay(System.getProperty("user.name"));
    System.out.println("No response from server as method is OneWay");
    System.out.println();

    try {
        System.out.println("Invoking pingMe, expecting exception...");
        port.pingMe();
    } catch (PingMeFault ex) {
        System.out.println("Expected exception: PingMeFault has occurred: " + ex.getMessage());
        FaultDetailDocument detailDocument = ex.getFaultInfo();
        FaultDetail detail = detailDocument.getFaultDetail();
        System.out.println("FaultDetail major:" + detail.getMajor());
        System.out.println("FaultDetail minor:" + detail.getMinor());
    }

    System.exit(0);
    // END SNIPPET: client
}

From source file:com.omertron.thetvdbapi.tools.TvdbParser.java

/**
 * Get the episode information from the URL
 *
 * @param urlString//w  w  w  . j a  va2  s . co m
 * @param bannerMirror
 * @return
 */
public static Episode getEpisode(String urlString, String bannerMirror) {
    Episode episode = new Episode();
    NodeList nlEpisode;
    Node nEpisode;
    Element eEpisode;

    try {
        Document doc = DOMHelper.getEventDocFromUrl(urlString);

        if (doc != null) {
            nlEpisode = doc.getElementsByTagName(EPISODE);
            for (int loop = 0; loop < nlEpisode.getLength(); loop++) {
                nEpisode = nlEpisode.item(loop);
                if (nEpisode.getNodeType() == Node.ELEMENT_NODE) {
                    eEpisode = (Element) nEpisode;
                    episode = parseNextEpisode(eEpisode, bannerMirror);
                    if (episode != null) {
                        // We only need the first episode
                        break;
                    }
                }
            }
        }
    } catch (WebServiceException ex) {
        LOG.warn("Series error: " + ex.getMessage(), ex);
    }

    return episode;

}

From source file:com.omertron.thetvdbapi.tools.TvdbParser.java

/**
 * Get a list of banners from the URL/*from  ww w . j  a v  a2 s . co  m*/
 *
 * @param urlString
 * @param bannerMirror
 * @return
 */
public static Banners getBanners(String urlString, String bannerMirror) {
    Banners banners = new Banners();
    Banner banner;

    NodeList nlBanners;
    Node nBanner;
    Element eBanner;

    try {
        Document doc = DOMHelper.getEventDocFromUrl(urlString);

        if (doc != null) {
            nlBanners = doc.getElementsByTagName(BANNER);
            for (int loop = 0; loop < nlBanners.getLength(); loop++) {
                nBanner = nlBanners.item(loop);
                if (nBanner.getNodeType() == Node.ELEMENT_NODE) {
                    eBanner = (Element) nBanner;
                    banner = parseNextBanner(eBanner, bannerMirror);
                    if (banner != null) {
                        banners.addBanner(banner);
                    }
                }
            }
        }
    } catch (WebServiceException ex) {
        LOG.warn("Banners error: " + ex.getMessage(), ex);
    }

    return banners;
}

From source file:com.omertron.thetvdbapi.tools.TvdbParser.java

/**
 * Get all the episodes from the URL/*from w w w.ja  v a 2 s.c  o  m*/
 *
 * @param urlString
 * @param season
 * @param bannerMirror
 * @return
 */
public static List<Episode> getAllEpisodes(String urlString, int season, String bannerMirror) {
    List<Episode> episodeList = new ArrayList<Episode>();
    Episode episode;
    NodeList nlEpisode;
    Node nEpisode;
    Element eEpisode;

    try {
        Document doc = DOMHelper.getEventDocFromUrl(urlString);
        nlEpisode = doc.getElementsByTagName(EPISODE);
        for (int loop = 0; loop < nlEpisode.getLength(); loop++) {
            nEpisode = nlEpisode.item(loop);
            if (nEpisode.getNodeType() == Node.ELEMENT_NODE) {
                eEpisode = (Element) nEpisode;
                episode = parseNextEpisode(eEpisode, bannerMirror);
                if ((episode != null) && (season == -1 || episode.getSeasonNumber() == season)) {
                    // Add the episode only if the season is -1 (all seasons) or matches the season
                    episodeList.add(episode);
                }
            }
        }
    } catch (WebServiceException ex) {
        LOG.warn("All Episodes error: " + ex.getMessage(), ex);
    }

    return episodeList;
}

From source file:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Get the encoded username required to authenticate user to BWS.
 *
 * @return Returns a string containing the encoded username if successful, and null otherwise.
 *
 *****************************************************************************************************************
 *///  w  w w .  ja v  a 2s.  co  m
public static String getEncodedUserName(String username, Authenticator authenticator,
        CredentialType credentialType, String domain) throws WebServiceException {
    final String METHOD_NAME = "getEncodedUserName()";
    final String BWS_API_NAME = "_bwsUtil.getEncodedUsername()";
    logMessage("Entering %s", METHOD_NAME);
    String returnValue = null;

    GetEncodedUsernameRequest request = new GetEncodedUsernameRequest();
    request.setMetadata(REQUEST_METADATA);
    request.setUsername(username);
    request.setOrgUid(REQUEST_METADATA.getOrganizationUid());
    request.setAuthenticator(authenticator);

    request.setCredentialType(credentialType);
    request.setDomain(domain);

    GetEncodedUsernameResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bwsUtil.getEncodedUsername(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")) {
        returnValue = response.getEncodedUsername();
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
    }

    if (Base64.isBase64(returnValue)) {
        logMessage("Decoded value of encoded username \"%s\"",
                StringUtils.newStringUtf8(Base64.decodeBase64(returnValue)));
    } else {
        logMessage("Value of encoded username \"%s\"", returnValue);
    }
    logMessage("Exiting %s", METHOD_NAME);
    return returnValue;
}

From source file:codesample.AuthenticationSample.java

/*****************************************************************************************************************
 *
 * Get the authenticator object for the authenticator name.
 *
 * @param authenticatorName A string containing the name of the desired authenticator.
 * @return Returns the requested authenticator if it is found, null otherwise.
 *
 *****************************************************************************************************************
 *///w ww .j a  va 2  s. c om
public static Authenticator getAuthenticator(String authenticatorName) throws WebServiceException {
    final String METHOD_NAME = "getAuthenticator()";
    final String BWS_API_NAME = "_bwsUtil.getAuthenticators()";
    logMessage("Entering %s", METHOD_NAME);
    Authenticator returnValue = null;

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

    GetAuthenticatorsResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bwsUtil.getAuthenticators(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.getAuthenticators() != null && !response.getAuthenticators().isEmpty()) {
            for (Authenticator authenticator : response.getAuthenticators()) {
                if (authenticator.getName().equalsIgnoreCase(authenticatorName)) {
                    returnValue = authenticator;
                    break;
                }
            }

            if (returnValue == null) {
                logMessage("Could not find \"%s\" in GetAuthenticatorsResponse", authenticatorName);
            }
        } else {
            logMessage("No authenticators in GetAuthenticatorsResponse");
        }
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
    }

    logMessage("Exiting %s with %s", METHOD_NAME,
            returnValue == null ? "\"null\"" : "Authenticator object (Name \"" + returnValue.getName() + "\")");
    return returnValue;
}

From source file:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Get the authenticator object for the authenticator name.
 *
 * @param authenticatorName/*from   w w w  . j ava 2  s .c  o m*/
 *            A string containing the name of the desired authenticator.
 * @return Returns the requested authenticator if it is found, null otherwise.
 *
 *******************************************************************************************************************
 */
public static Authenticator getAuthenticator(String authenticatorName) {
    final String METHOD_NAME = "getAuthenticator()";
    final String BWS_API_NAME = "_bwsUtil.getAuthenticators()";
    logMessage("Entering %s", METHOD_NAME);
    Authenticator returnValue = null;

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

    GetAuthenticatorsResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bwsUtil.getAuthenticators(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.getAuthenticators() != null && !response.getAuthenticators().isEmpty()) {
            for (Authenticator authenticator : response.getAuthenticators()) {
                if (authenticator.getName().equalsIgnoreCase(authenticatorName)) {
                    returnValue = authenticator;
                    break;
                }
            }

            if (returnValue == null) {
                logMessage("Could not find \"%s\" in GetAuthenticatorsResponse", authenticatorName);
            }
        } else {
            logMessage("No authenticators in GetAuthenticatorsResponse");
        }
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
    }

    logMessage("Exiting %s with %s", METHOD_NAME,
            returnValue == null ? "\"null\"" : "Authenticator object (Name \"" + returnValue.getName() + "\")");
    return returnValue;
}

From source file:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Get the encoded username required to authenticate user to BWS.
 *
 * @param username//from  www .j  av a 2  s  .  co  m
 *            A string containing the username to encode.
 * @param authenticator
 *            The authenticator.
 * @return Returns a string containing the encoded username if successful, and a null message string otherwise.
 *
 *******************************************************************************************************************
 */
public static String getEncodedUserName(String username, Authenticator authenticator) {
    final String METHOD_NAME = "getEncodedUserName()";
    final String BWS_API_NAME = "_bwsUtil.getEncodedUsername()";
    logMessage("Entering %s", METHOD_NAME);
    String returnValue = null;

    GetEncodedUsernameRequest request = new GetEncodedUsernameRequest();
    request.setMetadata(REQUEST_METADATA);
    request.setUsername(username);
    request.setOrgUid(REQUEST_METADATA.getOrganizationUid());
    request.setAuthenticator(authenticator);

    CredentialType credentialType = new CredentialType();
    credentialType.setPASSWORD(true);
    credentialType.setValue("PASSWORD");
    request.setCredentialType(credentialType);

    GetEncodedUsernameResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bwsUtil.getEncodedUsername(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")) {
        returnValue = response.getEncodedUsername();
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
    }

    if (Base64.isBase64(returnValue)) {
        logMessage("Decoded value of encoded username \"%s\"",
                StringUtils.newStringUtf8(Base64.decodeBase64(returnValue)));
    } else {
        logMessage("Value of encoded username \"%s\"", returnValue);
    }
    logMessage("Exiting %s", METHOD_NAME);
    return returnValue;
}

From source file:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Retrieves a single user using an email address. If more or less than one result is found, that is treated as an
 * error.//w w  w  .  j a v  a2 s  . c  o  m
 *
 * @return Returns a User object if user is found, and null otherwise.
 *
 *******************************************************************************************************************
 */
public static User getUser() {
    final String METHOD_NAME = "getUser()";
    final String BWS_API_NAME = "_bws.getUsers()";
    logMessage("Entering %s", METHOD_NAME);
    User returnValue = null;

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

    GetUsersSearchCriteria searchCriteria = new GetUsersSearchCriteria();

    // Search for a user by emailAddress
    searchCriteria.setEmailAddress(DISPLAY_USER_DETAIL_EMAIL);
    request.setSearchCriteria(searchCriteria);

    /*
     * The pageSize value of 2 is used to help determine if exactly 1 user was found. Using a pageSize value
     * of 2 avoids the overhead of retrieving more than 2 search results.
     */
    request.setPageSize(2);

    GetUsersSortBy sortBy = new GetUsersSortBy();
    sortBy.setEMAILADDRESS(true);
    sortBy.setValue("EMAIL_ADDRESS");
    request.setSortBy(sortBy);

    GetUsersResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bws.getUsers(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.getUsers() != null && response.getUsers().size() == 1) {
            // Returns the first user object in the users list.
            returnValue = response.getUsers().get(0);
        } else if (response.getUsers() != null && response.getUsers().size() > 1) {
            // Returns the first user object in the users list.
            returnValue = response.getUsers().get(0);
            logMessage(
                    "More than one user was found with email address search criteria \"%s\", first user result"
                            + " will be used.",
                    DISPLAY_USER_DETAIL_EMAIL);
        } else {
            logMessage("No user was found with email address \"%s\"", DISPLAY_USER_DETAIL_EMAIL);
        }
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
    }

    logMessage("Exiting %s with %s", METHOD_NAME,
            returnValue == null ? "\"null\"" : "User object (UID \"" + returnValue.getUid() + "\")");
    return returnValue;
}

From source file:Java_BWS_Sample.SampleBwsClient.java

/*******************************************************************************************************************
 *
 * Creates a user using an email address.
 *
 * @return Returns true if createUsers is successful, and false otherwise.
 *
 *******************************************************************************************************************
 */// ww w  .  j  a  v a2  s .c o  m
public static boolean createUser() {
    final String METHOD_NAME = "createUser()";
    final String BWS_API_NAME = "_bws.createUsers()";
    logMessage("Entering %s", METHOD_NAME);
    boolean returnValue = false;

    // Create the request object.
    CreateUsersRequest createUsersRequest = new CreateUsersRequest();
    createUsersRequest.setMetadata(REQUEST_METADATA);

    NewUser newUser = new NewUser();

    // To create an administrator user, create and set the "UserAttributes" and the roleUid field.
    AccountAttributes accountAttributes = new AccountAttributes();

    logMessage("Email address set to \"%s\"", CREATE_NEW_USER_EMAIL);

    // Value of the variable "CREATE_NEW_USER_EMAIL" is used to create a device-enabled user.
    accountAttributes.setEmailAddress(CREATE_NEW_USER_EMAIL);

    newUser.setAccountAttributes(accountAttributes);

    // Server value is validated and then ignored.
    newUser.setServer(null);

    createUsersRequest.getNewUsers().add(newUser);
    CreateUsersResponse response = null;
    try {
        logRequest(BWS_API_NAME);
        response = _bws.createUsers(createUsersRequest);
        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) {
            for (IndividualResponse individualResponse : response.getIndividualResponses()) {
                displayResult("User created with UID \"%s\"", individualResponse.getUid());
                displayResult("Email address used in creation is \"%s\"", accountAttributes.getEmailAddress());
            }

            returnValue = true;
        }
    } else {
        logMessage("Error Message: \"%s\"", response.getReturnStatus().getMessage());
        if (response.getIndividualResponses() != null) {
            for (IndividualResponse individualResponse : response.getIndividualResponses()) {
                logMessage("Individual Response - Code: \"%s\", Message: \"%s\"",
                        individualResponse.getReturnStatus().getCode(),
                        individualResponse.getReturnStatus().getMessage());
            }
        }
    }

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