Ejemplo n.º 1
0
        internal MetadataSet GetMetadataInternal(EndpointAddress address, MetadataExchangeClientMode mode)
        {
            if (binding == null)
            {
                binding = MetadataExchangeBindings.CreateMexHttpBinding();
            }

            MetadataProxy proxy = new MetadataProxy(binding, address);

            proxy.Open();

            SMMessage msg = SMMessage.CreateMessage(
                MessageVersion.Soap12WSAddressing10,
                "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");

            msg.Headers.ReplyTo = new EndpointAddress(
                "http://www.w3.org/2005/08/addressing/anonymous");
            //msg.Headers.From = new EndpointAddress ("http://localhost");
            msg.Headers.To        = address.Uri;
            msg.Headers.MessageId = new UniqueId();

            SMMessage ret;

            try {
                ret = proxy.Get(msg);
            } catch (Exception e) {
                throw new InvalidOperationException(
                          "Metadata contains a reference that cannot be resolved : " + address.Uri.AbsoluteUri, e);
            }

            return(MetadataSet.ReadFrom(ret.GetReaderAtBodyContents()));
        }
        internal MetadataSet GetMetadataInternal(EndpointAddress address, MetadataExchangeClientMode mode)
        {
            // FIXME: give dialect and identifier
            var cf = GetChannelFactory(address, null, null);

            cf.Open();
            var proxy           = cf.CreateChannel();
            var asClientChannel = proxy as IClientChannel;

            if (asClientChannel == null)
            {
                throw new InvalidOperationException("The channel factory must return an IClientChannel implementation");
            }
            asClientChannel.OperationTimeout = OperationTimeout;
            asClientChannel.Open();

            SMMessage msg = SMMessage.CreateMessage(
                MessageVersion.Soap12WSAddressing10,
                "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get");

            msg.Headers.ReplyTo = new EndpointAddress(
                "http://www.w3.org/2005/08/addressing/anonymous");
            //msg.Headers.From = new EndpointAddress ("http://localhost");
            msg.Headers.To        = address.Uri;
            msg.Headers.MessageId = new UniqueId();

            SMMessage ret;

            try
            {
                ret = proxy.Get(msg);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(
                          "Metadata contains a reference that cannot be resolved : " + address.Uri.AbsoluteUri, e);
            }

            return(MetadataSet.ReadFrom(ret.GetReaderAtBodyContents()));
        }