我无法在WCF服务中添加HTTP端点。 WCF托管在Windows服务应用程序中。实际上我的app.config是这样的:
<system.serviceModel>
<services>
<service name="Test.Service" behaviorConfiguration="ServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:8090" />
<add baseAddress="http://localhost:8099" />
</baseAddresses>
</host>
<endpoint binding="wsHttpBinding" bindingConfiguration="httpBinding" contract="Test.IService"/>
<endpoint binding="wsHttpBinding" bindingConfiguration="httpsBinding" contract="Test.IService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="httpsBinding">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
<binding name="httpBinding">
<security mode="None"/>
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<serviceCertificate
storeLocation="LocalMachine"
storeName="My"
x509FindType="FindBySubjectName"
findValue="server"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
服务启动,但是当我尝试访问http或https URL时,IncludeExceptionDetailInFaults在浏览器上阻止了此异常:
**Endpoint: https://localhost:8090/ ----> System.NullReferenceException**
如何在app.config中正确添加另一个端点?
编辑:启动服务的代码:
public class HostService
{
public static void Main( string[] args )
{
var host = new ServiceHost(typeof(Test.Service));
host.Open();
console.writeline("service starts");
console.Readkey();
host.Close();
}
}