Example #1
0
        void IServiceBehavior.ApplyDispatchBehavior(
            ServiceDescription description,
            ServiceHostBase serviceHostBase)
        {
            ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension(serviceHostBase);

            foreach (ChannelDispatcher dispatcher in serviceHostBase.ChannelDispatchers)
            {
                if (IncludeExceptionDetailInFaults)                 // may be set also in ServiceBehaviorAttribute
                {
                    dispatcher.IncludeExceptionDetailInFaults = true;
                }
            }

            if (HttpHelpPageEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("http", HttpHelpPageUrl);
                if (uri != null)
                {
                    // FIXME: wrong. It should add help page
                    sme.EnsureChannelDispatcher(false, "http", uri, HttpHelpPageBinding);
                }
            }

            if (HttpsHelpPageEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("https", HttpsHelpPageUrl);
                if (uri != null)
                {
                    // FIXME: wrong. It should add help page
                    sme.EnsureChannelDispatcher(false, "https", uri, HttpsHelpPageBinding);
                }
            }
        }
        void IServiceBehavior.ApplyDispatchBehavior(
            ServiceDescription description,
            ServiceHostBase serviceHostBase)
        {
            ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension(serviceHostBase);

            //Find ChannelDispatcher for Mex, and add a MexInstanceContextProvider
            //to it
            foreach (ChannelDispatcherBase cdb in serviceHostBase.ChannelDispatchers)
            {
                ChannelDispatcher cd = cdb as ChannelDispatcher;
                if (cd == null)
                {
                    continue;
                }

                foreach (EndpointDispatcher ed in cd.Endpoints)
                {
                    if (ed.ContractName == MexContractName)
                    {
                        ed.DispatchRuntime.InstanceContextProvider = new MexInstanceContextProvider(serviceHostBase);
                    }
                }
            }

            if (HttpGetEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("http", HttpGetUrl);
                if (uri != null)
                {
                    sme.EnsureChannelDispatcher(true, "http", uri, HttpGetBinding);
                }
            }

            if (HttpsGetEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("https", HttpsGetUrl);
                if (uri != null)
                {
                    sme.EnsureChannelDispatcher(true, "https", uri, HttpsGetBinding);
                }
            }
        }
Example #3
0
        void IServiceBehavior.ApplyDispatchBehavior(
            ServiceDescription description,
            ServiceHostBase serviceHostBase)
        {
            ServiceMetadataExtension sme = ServiceMetadataExtension.EnsureServiceMetadataExtension(serviceHostBase);

            foreach (var dispatcherBase in serviceHostBase.ChannelDispatchers)
            {
                var dispatcher = dispatcherBase as ChannelDispatcher;
                if (dispatcher == null) // non-ChannelDispatcher ChannelDispatcherBase instance.
                {
                    continue;
                }
                if (IncludeExceptionDetailInFaults) // may be set also in ServiceBehaviorAttribute
                {
                    dispatcher.IncludeExceptionDetailInFaults = true;
                }
            }

            if (HttpHelpPageEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("http", HttpHelpPageUrl);
                if (uri != null)
                {
                    sme.EnsureChannelDispatcher(false, "http", uri, HttpHelpPageBinding);
                }
            }

            if (HttpsHelpPageEnabled)
            {
                Uri uri = serviceHostBase.CreateUri("https", HttpsHelpPageUrl);
                if (uri != null)
                {
                    sme.EnsureChannelDispatcher(false, "https", uri, HttpsHelpPageBinding);
                }
            }
        }