public static Request createRequest(String xmlRequest) throws ParserConfigurationException, SAXException, IOException, ValidationException {

        Document doc = RequestFactory.parseXml(xmlRequest);
        if (doc == null) {
            throw new SAXException("Non valid request XML");
        }

        Request req = null;
        String rqType = getRequestType(doc);

        if (rqType.equals("register")) {
            req = createRegisterRequest(doc);
        } else if (rqType.equals("bet")) {
            req = createBetRequest(doc);
        } else if (rqType.equals("spin")) {
            req = createSpinRequest(doc);
        } else {
            throw new ValidationException("The request type is not one of {register, bet, spin}");

        }

        return req;
    }