1
我有netTcp主機工作;我們正在嘗試添加對Mac的支持,因此添加了BasicHttpBinding。最終,我想使用相同的ServiceHost來做到這一點,但是當我嘗試瀏覽到http://localhost:8085/Lss/test(測試是一個OperationContract,我只是爲了輸出一些文本而設計的),它會以「400錯誤請求」作爲響應。我錯過了什麼?一個ServiceHost,兩個端點(net.tcp&basic http)
這是作爲Windows服務託管的。下面是App.config中設置的樣子:
<service name="Wcf.Lss" behaviorConfiguration="DefaultBehavior">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="netTcpBinding" contract="Wcf.ILss"/>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="" contract="Wcf.ILss" />
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" maxReceivedMessageSize="9655360" maxBufferSize="9655360" maxBufferPoolSize="524288">
<readerQuotas maxArrayLength = "932000" maxStringContentLength="900000" maxDepth="32"/>
<security mode="None"></security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior" >
<serviceDebug includeExceptionDetailInFaults="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
的主機配置是這樣的:
var baseTcpUri = new Uri("net.tcp://localhost:8080/Lss");
var baseHttpUri = new Uri("http://localhost:8085/Lss");
var host = new ServiceHost(wcfSingleton, baseTcpUri, baseHttpUri);
host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpGetEnabled = true, HttpGetUrl=baseHttpUri });
var throttlingBehavior = new System.ServiceModel.Description.ServiceThrottlingBehavior();
throttlingBehavior.MaxConcurrentCalls = 50;
throttlingBehavior.MaxConcurrentInstances = 10;
throttlingBehavior.MaxConcurrentSessions = 10;
host.Description.Behaviors.Add(throttlingBehavior);
host.Open();