public IEnumerator <ITask> SetVoiceHandler(SetVoice setVoice)
        {
            // Use try/catch to respond with meaningful error in case of an exception
            try
            {
                SetVoice(setVoice.Body.Voice);
            }
            catch (ArgumentException e)
            {
                setVoice.ResponsePort.Post(
                    Fault.FromCodeSubcodeReason(
                        W3C.Soap.FaultCodes.Receiver,
                        DsspFaultCodes.OperationFailed,
                        e.Message
                        )
                    );
                yield break;
            }

            SaveState(_state);

            // Notify subscribers of state change
            Replace replace = new Replace();

            replace.Body = _state;
            SendNotification <Replace>(_subMgrPort, replace);

            setVoice.ResponsePort.Post(DefaultUpdateResponseType.Instance);
            yield break;
        }
        public IEnumerator <ITask> HttpPostHandler(HttpPost httpPost)
        {
            ReadFormData readForm = new ReadFormData(httpPost);

            _utilities.Post(readForm);

            PortSet <NameValueCollection, Exception> readFormResponsePort = readForm.ResultPort;

            yield return((Choice)readFormResponsePort);

            Exception exception = (Exception)readFormResponsePort;

            if (exception != null)
            {
                LogError(exception);
                httpPost.ResponsePort.Post(Fault.FromException(exception));
                yield break;
            }

            NameValueCollection collection = (NameValueCollection)readFormResponsePort;
            string voice      = collection["Voice"];
            string rate       = collection["Rate"];
            string volume     = collection["Volume"];
            string speechText = collection["SpeechText"];

            PortSet <DefaultUpdateResponseType, Fault> responsePort = null;

            if (!string.IsNullOrEmpty(voice))
            {
                SetVoice setVoice = new SetVoice(new SetVoiceRequest(voice));
                SpawnIterator(setVoice, SetVoiceHandler);

                responsePort = setVoice.ResponsePort;
            }
            else if (!string.IsNullOrEmpty(rate))
            {
                int rateInt;
                if (int.TryParse(rate, out rateInt))
                {
                    SetRate setRate = new SetRate();
                    setRate.Body.Rate = rateInt;
                    SpawnIterator(setRate, SetRateHandler);

                    responsePort = setRate.ResponsePort;
                }
            }
            else if (!string.IsNullOrEmpty(volume))
            {
                int volumeInt;

                if (int.TryParse(volume, out volumeInt))
                {
                    SetVolume setVolume = new SetVolume();
                    setVolume.Body.Volume = volumeInt;
                    SpawnIterator(setVolume, SetVolumeHandler);

                    responsePort = setVolume.ResponsePort;
                }
            }
            else if (!string.IsNullOrEmpty(speechText))
            {
                SayText sayText = new SayText(new SayTextRequest(speechText));
                SpawnIterator(sayText, SayTextHandler);

                responsePort = sayText.ResponsePort;
            }

            if (responsePort != null)
            {
                yield return((Choice)responsePort);

                Fault fault = (Fault)responsePort;
                if (fault != null)
                {
                    LogError("Unable to perform post operation", fault);
                    httpPost.ResponsePort.Post(fault);
                    yield break;
                }
            }

            httpPost.ResponsePort.Post(new HttpResponseType(
                                           HttpStatusCode.OK,
                                           _state,
                                           base.StateTransformPath // Use the transform declared on the State
                                           ));
            yield break;
        }