【发布时间】:2013-12-17 06:04:46
【问题描述】:
我在 Web 应用程序中添加了一个 RESTful WCF 服务(Righclicked 解决方案并添加了 WCF 服务),并且在运行它时将 url 公开为 svcutil.exe http://localhost:62783/Service1.svc?wsdl 但我尝试从像 http://localhost:62783/AuthenticateUser 这样的 RESTCLIENT 调用该服务 UriTemplate正在抛出类似
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
但如果我创建一个单独的 RESTful WCF 服务并从 RESTCLIENT 调用工作正常。这是我的代码
[OperationContract]
string AuthenticateUser1();
和
[WebInvoke(UriTemplate = "/AuthenticateUser", Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
public string AuthenticateUser1()
{
return string.Format("Token {0}", new Guid().ToString());
}
和配置
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
有什么建议吗??
【问题讨论】:
-
你提供的
AuthenticateUser1方法是Service1.svc的一部分吗? -
是的,它是 Service1.SVC 的一部分
-
你的服务主机的 bindingAddress 是什么?
标签: c# asp.net wcf restful-url rest-client