2011-08-17 52 views
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(); 

回答

0

您无法浏览到的操作,你只能浏览到其在服务你案件托管在基地址。所以,当你浏览到“http:// localhost:8085/Lss”时,你应该会看到标准的WCF测试页面。