public function callMethod($name, $httpMethod = "POST", $params = array(), $payload = null, $returnClass = null, $expectedExceptions = null) {

        $objectToFormatConverter = $this->dataFormat == self::DATA_FORMAT_JSON ? new ObjectToJSONConverter() : new ObjectToXMLConverter();
        $formatToObjectConverter = $this->dataFormat == self::DATA_FORMAT_JSON ? new JSONToObjectConverter() : new XMLToObjectConverter();


        if (!is_array($expectedExceptions)) {
            $expectedExceptions = array();
        }

        if (!ArrayUtils::isAssociative($expectedExceptions)) {
            $expectedExceptions = array_combine($expectedExceptions, $expectedExceptions);
        }

        $parameters = $this->globalParameters;
        if (is_array($parameters) && is_array($params)) {
            $parameters = array_merge($parameters, $params);
        }

        foreach ($parameters as $key => $value) {
            $parameters[$key] = $value;
        }

        if ($payload) {
            $payload = $objectToFormatConverter->convert($payload);
        }

        $request = new HttpRemoteRequest($this->webServiceURL . "/" . $name, $httpMethod, $parameters, $payload);

        try {
            $result = $request->dispatch();

            if ($this->dataFormat == self::DATA_FORMAT_JSON) {
                $result = $formatToObjectConverter->convert($result);
            }


            if ($returnClass) {
                $result = SerialisableArrayUtils::convertArrayToSerialisableObjects($result, $returnClass);
            }

            return $result;

        } catch (HttpRequestErrorException $e) {

            $response = $e->getResponse();
            
            if ($this->dataFormat == self::DATA_FORMAT_JSON) {
                $response = $formatToObjectConverter->convert($response);


                if ($response["exceptionClass"] && isset($expectedExceptions[$response["exceptionClass"]])) {
                    $response = SerialisableArrayUtils::convertArrayToSerialisableObjects($response, $expectedExceptions[$response["exceptionClass"]]);
                }

            }

            if ($response instanceof SerialisableException) {
                throw $response;
            } else {
                throw $e;
            }

        }


    }