日期:2014-05-17  浏览次数:20347 次

WCF 怎么直接运行
我新建了一个wcf服务
  [ServiceContract]
  public interface IService1
  {
  [WebGet(UriTemplate = "/GetString")]
  [OperationContract]
  string GetString();
  // TODO: 在此添加您的服务操作
  }

  public class Service1 : IService1
  {

  public string GetString()
  {
  return "Hello world";
  }
  }

在vs2010里面直接右键 在浏览器查看 Service1.svc

我怎么才可以运行http://localhost:11301/Service1.svc/GetString

现在运行http://localhost:11301/Service1.svc/GetString返回400啊 是不是web config要配置啊

------解决方案--------------------
http://wcftutorial.net/WCF-Self-Hosting.aspx

wcf自承载,也就是在自己的应用程序中承载wcf服务。
要点是创建一个ServiceHost对象,并且让它承载服务。
------解决方案--------------------
麻烦你找个wcf的例子看下
------解决方案--------------------
可以使用WCF Test Client (WcfTestClient.exe)测试WCF。 

路径
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\

其中Microsoft Visual Studio 9.0取决于版本

参考:
http://msdn.microsoft.com/en-us/library/bb552364.aspx