简体   繁体   English

WCF服务应用程序使用WebGet返回404

[英]WCF Service Application returns 404 using WebGet

I created just the most basic WCF Service Application to do some prototyping, but I can't get the WebGet implementation to work. 我只是创建了最基本的WCF服务应用程序来进行一些原型设计,但无法使WebGet实现正常工作。

Here's my interface: 这是我的界面:

[ServiceContract]
public interface IService
{
    [OperationContract]
    [WebGet(UriTemplate = "/rest/{value}")]
    string Test(string value);
}

Here's the implementation: 这是实现:

public string Test(string value)
{
    return string.Format("You entered: {0}", value);
}

But if I go to http://localhost:3305/rest/Hello in my browser, I get a 404. I'm using the VS 2008 webserver. 但是,如果我在浏览器中转到http:// localhost:3305 / rest / Hello ,则会得到404。我正在使用VS 2008 Web服务器。

I think your missing the actual service name. 我认为您缺少实际的服务名称。

http://localhost:3305/yourservicename.svc/rest/Hello HTTP://本地主机:3305 / yourservicename.svc / REST /你好

Update 更新

config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);

public static void InitializeService(DataServiceConfiguration config)
    {
        // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
        // Examples:
         config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
         config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);
        //config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM