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

如果我尝试在浏览器中运行它,我会得到:The type 'WcfService2.Service1', provided as the Service attribute value in the ServiceHost directive could not be found.
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();
}
}
}发布于 2012-03-16 05:27:49
您正在使用WebHttpBinding定义一个REST样式的 WCF服务。
WCF Test Client只能用于SOAP服务,而不能用于REST服务。可以使用常规浏览器或像Fiddler这样的工具测试REST服务。
您收到的错误消息几乎表明您周围的某个地方也有一个*.svc,这阻碍了您的工作。真的是这样吗?
https://stackoverflow.com/questions/9728417
复制相似问题