在尝试从我的服务中获取时,似乎遇到了未找到服务端点的问题。未找到服务终点?
如果我尝试http://localhost:8000/hello/help我应该期待看到<string>You entered help <string>
但我只能得到没有终端?我没有碰过我的配置文件,我只是从一个控制台应用程序托管。
主持人:
namespace Host
{
class Program
{
static void Main(string[] args)
{
WebHttpBinding binding = new WebHttpBinding();
WebServiceHost host =
new WebServiceHost(typeof(Service1));
host.AddServiceEndpoint(typeof(IService1),
binding,
"http://localhost:8000/hello");
host.Open();
Console.WriteLine("Hello world service");
Console.WriteLine("Press <RETURN> to end service");
Console.ReadLine();
}
}
}
服务1:
namespace WcfServiceLibrary1
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IService1
{
public string GetData(string value)
{
return string.Format("You entered: {0}", value);
}
IService1:
[ServiceContract]
public interface IService1
{
[WebGet(UriTemplate = "/{value}")]
string GetData(string value);
嗨Justin很高兴再次见到你,/ {value}是因为我的网址是:http:// localhost:8000/hello没有结束斜线/我认为它可以是或可以不管是否取走它都不能解决问题。 – 2012-03-25 22:00:28
@Garrith我已经更新了我的答案,我注意到你也缺少OperationContractAttribute。 – 2012-03-25 22:08:07
哈哈操作合同失踪! +1 – 2012-03-25 22:09:55