首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >元数据问题wcf rest

元数据问题wcf rest
EN

Stack Overflow用户
提问于 2012-03-16 05:25:39
回答 1查看 135关注 0票数 0

所以尝试创建一个rest服务,但我总是得到一个错误:

如果我尝试在浏览器中运行它,我会得到:The type 'WcfService2.Service1', provided as the Service attribute value in the ServiceHost directive could not be found.

代码语言:javascript
复制
namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public class HelloWorldService
    {
        [OperationContract]
        [WebGet(UriTemplate = "")]
        public string HelloWorld()
        {
            return "Hello world!";
        }
    }
}

namespace WcfService2
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.

    class Program
    {
        static void Main(string[] args)
        {
            WebHttpBinding binding = new WebHttpBinding();
            WebServiceHost host =
            new WebServiceHost(typeof(HelloWorldService));
            host.AddServiceEndpoint(typeof(HelloWorldService),
            binding,
            "http://localhost:8000/Hello");
            host.Open();
            Console.WriteLine("Hello world service");
            Console.WriteLine("Press <RETURN> to end service");
            Console.ReadLine();
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-03-16 05:27:49

您正在使用WebHttpBinding定义一个REST样式的 WCF服务。

WCF Test Client只能用于SOAP服务,而不能用于REST服务。可以使用常规浏览器或像Fiddler这样的工具测试REST服务。

您收到的错误消息几乎表明您周围的某个地方也有一个*.svc,这阻碍了您的工作。真的是这样吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9728417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档