繁体   English   中英

一个 ServiceHost,两个端点(net.tcp 和基本 http)

[英]One ServiceHost, two end points (net.tcp & basic http)

我有工作的 netTcp 主机工作; 我们正在尝试添加对 Mac 的支持,因此正在添加 BasicHttpBinding。 最终,我想使用相同的 ServiceHost 来执行此操作,但是当我尝试浏览到http://localhost:8085/Lss/test时(测试是我为 output 设计的一个 OperationContract 一些文本)它以“400 错误请求”响应。 我错过了什么?

这是作为 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();

您无法浏览到操作,只能浏览到在您的情况下托管在基地址的服务。 因此,当您浏览到“http://localhost:8085/Lss”时,您应该会看到标准的 WCF 测试页面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM