开发者

My IIS does not recognize my WCF custom binding

Today, I have a problem with hosting my custom service host using custom binding. I have tried to implement ServiceHostFactory but when i right click to view with in browser, the error appeared as IIS does not recognize my custom binding (duplexHttpBinding).

My web.config is here:

<services>
        <service name="TestWcf.Service1"
            behaviorConfiguration="Service1Behavior">
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost:8888/Service1"/>
                </baseAddresses>
            </host>
            <endpoint
                address="http://localhost:9999/Service1"
                binding="duplexHttpBinding"
                bindingConfiguration="binding1"
                contract="TestWcf.IService" />
        </service>
    </services>

    <bindings>
        <duplexHttpBinding>
            <binding name="binding1"
                     closeTimeout="00:01:00"
                     openTimeout="00:01:00"
                     receiveTimeout="24.20:31:23.6470000"
                     sendTimeout="02:01:00"
                     session="ReliableSession"
                     sessionTimeout="00:10:00"
                     maxUndeliveredMessages="100"
                     maxMessagesInBatch="10"
                     maxPollingReplyInterval="00:02:00">
            </binding>
        </duplexHttpBinding>
    </bindings>

    <behaviors>
        <serviceBehaviors>
            <behavior name="Service1Behavior">
                <serviceMetadata httpGetEnabled="True" />
                <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

and code in dervied class is here:

public class CustomServiceHost : ServiceHostFactory
{
    public override ServiceHostBase CreateServiceHost(string service, Uri[] baseAddresses)
    {
        DuplexHttpBinding binding = new DuplexHttpBinding();
        binding.Name = "binding1";

        Uri baseAddress = new Uri("http://localhost:8888/Service1");
        Uri address = new Uri("http://localhost:9999/Service1");


        ServiceHost serviceHost = new ServiceHost(typeof(Service1), baseAddresses);
        serviceHost.AddServiceEndpoint(typeof(IService1), binding, address);

        return serviceHost;开发者_StackOverflow
    }
}

and in SVC file

<%@ ServiceHost Language="C#" Debug="true" Service="TestWcf.Service1" Factory="TestWcf.CustomServiceHost" %>  

Do I miss something in the context?

Thank you.


You must register new binding as binding extension in your configuration file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜