public IDelayedSOAPRequest ToConfigEndpoint(string endpointName)
        {
            Tuple <Uri, Binding> result = SOAPRequestHelper.GetConfigurationBinding(endpointName);

            _to      = result.Item1;
            _binding = result.Item2;

            if (_requestDone)
            {
                _dirty = true;
            }

            return(this);
        }
        public IDelayedSOAPRequest Request <T>(Expression <Action <T> > call)
        {
            _soapMessage = SOAPRequestHelper.GetSOAPMessage <T>(call, _binding);

            if (string.IsNullOrEmpty(_soapMessage))
            {
                throw new Exception("Unable to get soap envelope");
            }

            _requestDone = true;

            if (_dirty)
            {
                _dirty = false;
            }

            return(this);
        }
        public string Schedule()
        {
            if (_dirty)
            {
                throw new InvalidOperationException("The data that produced the request has changed. Produce another request.");
            }
            if (_to == null)
            {
                throw new ArgumentException("The To must be set");
            }

            using (ChannelFactory <ISchedulerService> ch = new ChannelFactory <ISchedulerService>(ClientUtilManager.Ask().EndpointConfigurationName))
            {
                ISchedulerService svc = ch.CreateChannel();

                return(svc.DelayedSOAPRequestMessage(_to.Host, _to.Port, Encoding.UTF8.GetBytes(SOAPRequestHelper.GetMangeldRequest(_soapMessage, _to)), _delay, _retryCount, _fireAndForget));
            }
        }