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();