Wcf ChannelFactory.EndPoint上的Address属性为null。终结点必须具有有效的地址
我有一个具有以下配置的WCF服务:Wcf ChannelFactory.EndPoint上的Address属性为null。终结点必须具有有效的地址,wcf,Wcf,我有一个具有以下配置的WCF服务: <service behaviorConfiguration="LoginService.LoginBehavior" name="AuthenticationServices.Login"> <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="WebHttpEnd
<service behaviorConfiguration="LoginService.LoginBehavior" name="AuthenticationServices.Login">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="WebHttpEndpointBinding"
contract="AuthenticationServices.ILoginService">
<identity>
现在,当我从控制台应用程序调用该服务时,它抛出以下错误:
Unhandled Exception: System.InvalidOperationException: The Address property on C
hannelFactory.Endpoint was null. The ChannelFactory's Endpoint must have a vali
d Address specified.
at System.ServiceModel.ChannelFactory.CreateEndpointAddress(ServiceEndpoint e
ndpoint)
at System.ServiceModel.ChannelFactory`1.CreateChannel()
您应该为服务或特定端点指定地址(如果有多个端点) 服务
<service behaviorConfiguration="LoginService.LoginBehavior" name="AuthenticationServices.Login">
<endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="WebHttpEndpointBinding"
contract="AuthenticationServices.ILoginService"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:5804/SimplePluginService.svc"/>
</baseAddresses>
</host>
对于端点
<endpoint address="myEndPoint" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="WebHttpEndpointBinding"
contract="AuthenticationServices.ILoginService"/>
端点的地址将添加在基址之后
如果您使用IIS托管WCF服务,则基址将取自IIS的调整,而不是取自
<endpoint address="myEndPoint" behaviorConfiguration="web" binding="webHttpBinding"
bindingConfiguration="WebHttpEndpointBinding"
contract="AuthenticationServices.ILoginService"/>