一个ServiceHost,两个端点(net.tcp& basic http)

时间:2011-08-17 15:49:33

标签: wcf c#-4.0 wcf-binding

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

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

1 个答案:

答案 0 :(得分:0)

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