0
今天,我使用custom binding託管我的自定義服務主機時遇到問題。我試圖實現ServiceHostFactory,但是當我右鍵單擊瀏覽器查看時,出現錯誤,因爲IIS無法識別我的自定義綁定(duplexHttpBinding)。我的IIS無法識別我的WCF自定義綁定
我的web.config是在這裏:
<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>
和dervied類代碼是在這裏:
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;
}
}
和SVC文件
<%@ ServiceHost Language="C#" Debug="true" Service="TestWcf.Service1" Factory="TestWcf.CustomServiceHost" %>
我懷念的東西在背景?
謝謝。
非常感謝:我完成之後,仍然發現錯誤「無協議綁定與給定地址匹配」http:// localhost:9999/Service1「。協議綁定在IIS或WAS配置的站點級別配置。 「對此有何建議? – tong 2011-03-10 03:26:27
您正在使用Https。在這種情況下,您的自定義綁定必須使用httpsTransport頻道。綁定配置中是否有任何安全元素?如果是,您必須將其配置爲傳輸模式。 – 2011-03-10 05:47:28