【发布时间】:2018-02-25 10:21:36
【问题描述】:
这是我的第一个 Web 服务,我正在尝试按照有关为 Web 服务创建自定义身份验证的教程进行操作,但遇到此错误时卡住了:
根据其数据类型“serviceNameType”,值“WcfOrderingService.Services.AuthenticationTokenService”无效 - 枚举约束失败。
网络配置:
<service name ="WcfOrderingService.Services.AuthenticationTokenService"
behaviorConfiguration="ServiceBehaviourHttp">
<endpoint address="" behaviorConfiguration="WcfOrderingService.AuthenticationTokenServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="WcfOrderingService.Services.AuthenticationTokenService.Authenticate" />
</service>
.svc.cs -
namespace WcfOrderingService.Services
{
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class AuthenticationTokenService
{
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
[OperationContract]
public string Authenticate(Credentials creds)
{
ICredentialsValidator validator = new CredentialsValidator();
if (validator.IsValid(creds))
return new TokenBuilder().Build(creds);
throw new InvalidCredentialException("Invalid credentials");
}
}
}
我已经尝试了我在网上找到的大多数东西、服务名称的变体等,但找不到答案。
提前致谢。
【问题讨论】:
标签: c# asp.net wcf web service