Пример #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()));
        }
Пример #2
0
 public ServiceMetadataEndpoint(EndpointAddress address)
     : this(MetadataExchangeBindings.CreateMexHttpBinding(), address)
 {
 }
Пример #3
0
 public ServiceMetadataEndpoint()
     : this(MetadataExchangeBindings.CreateMexHttpBinding(), null /*address*/)
 {
 }
Пример #4
0
 SMBinding CreateBinding(EndpointAddress address)
 {
     return(address.Uri.Scheme == Uri.UriSchemeHttps ?
            MetadataExchangeBindings.CreateMexHttpsBinding() :
            MetadataExchangeBindings.CreateMexHttpBinding());
 }
Пример #5
0
        // FIXME: distinguish HTTP and HTTPS in the Url properties.
        internal void EnsureChannelDispatcher(bool isMex, string scheme, Uri uri, WCFBinding binding)
        {
            if (isMex)
            {
                instance.WsdlUrl = uri;
            }
            else
            {
                instance.HelpUrl = uri;
            }

            if (dispatchers == null)
            {
                dispatchers = new Dictionary <Uri, ChannelDispatcher> ();
            }
            else if (dispatchers.ContainsKey(uri))
            {
                var info = dispatchers [uri].Listener.GetProperty <MetadataPublishingInfo> ();
                if (isMex)
                {
                    info.SupportsMex = true;
                }
                else
                {
                    info.SupportsHelp = true;
                }
                return;
            }

            if (binding == null)
            {
                switch (scheme)
                {
                case "http":
                    binding = MetadataExchangeBindings.CreateMexHttpBinding();
                    break;

                case "https":
                    binding = MetadataExchangeBindings.CreateMexHttpsBinding();
                    break;

                case "net.tcp":
                    binding = MetadataExchangeBindings.CreateMexTcpBinding();
                    break;

                case "net.pipe":
                    binding = MetadataExchangeBindings.CreateMexNamedPipeBinding();
                    break;
                }
            }

            CustomBinding cb = new CustomBinding(binding)
            {
                Name = ServiceMetadataBehaviorHttpGetBinding
            };

            cb.Elements.Find <MessageEncodingBindingElement> ().MessageVersion = MessageVersion.None;

            ServiceEndpoint se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IHttpGetHelpPageAndMetadataContract)), cb, new EndpointAddress(uri))
            {
                ListenUri = uri,
            };

            var channelDispatcher = new DispatcherBuilder().BuildChannelDispatcher(owner.Description.ServiceType, se, new BindingParameterCollection());
            // add HttpGetWsdl to indicate that the ChannelDispatcher is for mex or help.
            var listener = channelDispatcher.Listener as ChannelListenerBase;

            if (listener != null)
            {
                listener.Properties.Add(new MetadataPublishingInfo()
                {
                    SupportsMex = isMex, SupportsHelp = !isMex, Instance = instance
                });
            }
            channelDispatcher.Endpoints [0].DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(new InstanceContext(owner, instance));

            dispatchers.Add(uri, channelDispatcher);
            owner.ChannelDispatchers.Add(channelDispatcher);
        }
Пример #6
0
        // FIXME: if the ServiceDescription has a base address (e.g. http://localhost:8080) and HttpGetUrl is empty, it returns UnknownDestination while it is expected to return the HTTP help page.
        internal void EnsureChannelDispatcher(bool isMex, string scheme, Uri uri, WCFBinding binding)
        {
            if (isMex)
            {
                instance.WsdlUrl = uri;
            }
            else
            {
                instance.HelpUrl = uri;
            }

            if (dispatchers == null)
            {
                dispatchers = new Dictionary <Uri, ChannelDispatcher> ();
            }
            else if (dispatchers.ContainsKey(uri))
            {
                return;                 // already exists (e.g. reached here for wsdl while help is already filled on the same URI.)
            }
            if (binding == null)
            {
                switch (scheme)
                {
                case "http":
                    binding = MetadataExchangeBindings.CreateMexHttpBinding();
                    break;

                case "https":
                    binding = MetadataExchangeBindings.CreateMexHttpsBinding();
                    break;

                case "net.tcp":
                    binding = MetadataExchangeBindings.CreateMexTcpBinding();
                    break;

                case "net.pipe":
                    binding = MetadataExchangeBindings.CreateMexNamedPipeBinding();
                    break;
                }
            }

            CustomBinding cb = new CustomBinding(binding)
            {
                Name = ServiceMetadataBehaviorHttpGetBinding
            };

            cb.Elements.Find <MessageEncodingBindingElement> ().MessageVersion = MessageVersion.None;

            ServiceEndpoint se = new ServiceEndpoint(ContractDescription.GetContract(typeof(IHttpGetHelpPageAndMetadataContract)), cb, new EndpointAddress(uri))
            {
                ListenUri = uri,
            };

            var channelDispatcher = new DispatcherBuilder(Owner).BuildChannelDispatcher(owner.Description.ServiceType, se, new BindingParameterCollection());

            channelDispatcher.MessageVersion = MessageVersion.None;             // it has no MessageVersion.
            channelDispatcher.IsMex          = true;
            channelDispatcher.Endpoints [0].DispatchRuntime.InstanceContextProvider = new SingletonInstanceContextProvider(new InstanceContext(owner, instance));

            dispatchers.Add(uri, channelDispatcher);
            owner.ChannelDispatchers.Add(channelDispatcher);
        }