我正在嘗試構建一個小WCF服務並希望在測試應用程序中使用它。WCF服務創建
PFB服務代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace HelloIndigo
{
[ServiceContract(Namespace="http://www.thatindigoirl.com/samples/2006/06")]
public interface IHelloIndigoService
{
[OperationContract]
string HelloIndigo();
}
public class HelloIndigoService : IHelloIndigoService
{
public string HelloIndigo()
{
return "Hello indigo";
}
}
}
主機代碼:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Host
{
class Program
{
static void Main(string[] args)
{
using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService), new Uri("http://localhost:8000/HelloIndigo")))
{
host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService), new BasicHttpBinding(), @"HelloIndigoService");
host.Open();
Console.WriteLine("Press <ENTER> to terminate the service hosy");
Console.ReadLine();
}
}
}
}
每當我試圖運行主機我得到下面提到的錯誤host.Open()語句。
HTTP無法註冊URL http://+:8000/HelloIndigo/。您的 進程無權訪問此名稱空間的 (有關詳細信息,請參閱 http://go.microsoft.com/fwlink/?LinkId=70353 )。
誰能幫我這個
如果您發佈代碼,XML或數據樣本,請**在文本編輯器中突出顯示這些行,然後單擊編輯器工具欄上的「代碼示例」按鈕(「{}」)以精確地設置格式和語法突出顯示它! – 2011-05-07 12:51:31
最重要的部分 - 服務器端和客戶端的** configs **缺失。沒有這些,我們只能猜測..... – 2011-05-07 12:52:23
您是否在錯誤消息中點擊了Microsoft鏈接?它解釋了它是什麼。 – 2011-05-07 13:21:13