Uri EnsureAnonymous(Message message)
        {
            Uri to;

            if (IsDatagram)
            {
                to = message.Headers.To;
            }
            else
            {
                to = this.RemoteAddress.Uri;
            }

            if (to == null)
            {
                throw new InvalidOperationException(ExceptionMessages.WsmcNoToHeader);
            }
            else if (!MakeConnectionUtility.IsAnonymousUri(to))
            {
                throw new InvalidOperationException(String.Format
                                                        (ExceptionMessages.WsmcNotAnonUri, to));
            }

            return(to);
        }
        EndpointAddress GetAddress()
        {
            EndpointAddress address = null;

            if (this.IsMakeConnectionPollingMessage)
            {
                MakeConnectionMessageInfo  info  = MakeConnectionMessageInfo.ReadMessage(this.RequestMessage);
                MakeConnectionMessageFault fault = VerifyProtocolElements(info);

                if (fault == null)
                {
                    address = new EndpointAddress(info.Address);
                }
                else
                {
                    this.isFaulting = true;
                    IAsyncResult result = BeginReply(fault.CreateMessage(RequestMessage.Version), onFaultCompleted, this);
                    if (result.CompletedSynchronously)
                    {
                        OnFaultCompletedCore(result);
                    }
                }
            }
            else
            {
                // normal message, grab the reply-to
                address = this.RequestMessage.Headers.ReplyTo;
            }

            if (address != null)
            {
                this.addressIsAnonymousUri = MakeConnectionUtility.IsAnonymousUri(address.Uri);
            }

            return(address);
        }