Ejemplo n.º 1
0
 public static Binding CreateMexNamedPipeBinding()
 {
     return(MetadataExchangeBindings.CreateNamedPipeBinding());
 }
Ejemplo n.º 2
0
 public static Binding CreateMexHttpsBinding()
 {
     return(MetadataExchangeBindings.CreateHttpsBinding());
 }
Ejemplo n.º 3
0
 public static Binding CreateMexTcpBinding()
 {
     return(MetadataExchangeBindings.CreateTcpBinding());
 }
Ejemplo n.º 4
0
 SMBinding CreateBinding(EndpointAddress address)
 {
     return(address.Uri.Scheme == Uri.UriSchemeHttps ?
            MetadataExchangeBindings.CreateMexHttpsBinding() :
            MetadataExchangeBindings.CreateMexHttpBinding());
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 7
0
 public ServiceMetadataEndpoint(EndpointAddress address)
     : this(MetadataExchangeBindings.CreateMexHttpBinding(), address)
 {
 }
Ejemplo n.º 8
0
 public ServiceMetadataEndpoint() : this(MetadataExchangeBindings.CreateMexHttpBinding(), null)
 {
 }